home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games Extra 1996 September / Amiga Games Extra CD-ROM 9-1996.iso / userbox / publicdomain / typeface / source / typeface.c < prev    next >
C/C++ Source or Header  |  1996-06-01  |  85KB  |  3,128 lines

  1. /**************************/
  2. /*              */
  3. /* Typeface v1.2      */
  4. /* © 1995-96 David Kinder */
  5. /*              */
  6. /**************************/
  7.  
  8. #include "Typeface.h"
  9.  
  10. extern struct IntuitionBase *IntuitionBase;
  11. extern struct GfxBase *GfxBase;
  12. struct Library *AslBase, *BGUIBase, *DiskfontBase, *TextFieldBase;
  13. struct Library *IFFParseBase, *KeymapBase;
  14. struct Screen *Screen;
  15. struct Window *FontWnd, *OldWindowPtr;
  16. struct DrawInfo *ScrDrawInfo;
  17. struct List *CharWndList;
  18. struct MsgPort *WndMsgPort;
  19. struct Image *SizeImage, *LeftImage, *RightImage, *UpImage, *DownImage;
  20. struct TextFont *NewFont, *ScrFont, *FixFont;
  21. struct FontRequester *FontReq, *PrefsFontReq;
  22. struct ScreenModeRequester *PrefsScrReq;
  23. struct Hook *FontWndHook;
  24. struct Character CharBuffer[257];
  25. struct Character ClipChar;
  26. struct IBox CharSize, FontSize;
  27. struct NameInfo ModeIDName;
  28. Object *FontWndObj, *CharObj, *ScrollObj;
  29. Class *CharClass, *EditClass, *SlideClass, *LVClass;
  30. WORD SpaceTable[257], KernTable[257];
  31. ULONG FirstChar, LastChar, ScaleX, ScaleY, UseTable, ScrWidth, ScrHeight;
  32. char WinTitle[256], FontPath[256], SavePath[256], FontName[256];
  33. char *KeyLabelTable;
  34. BOOL CustomScreen = TRUE, ChangeScreen = FALSE, FlagError;
  35. BOOL NewCustom, NewWindow, MaxWindow = FALSE, ConfirmQuit = FALSE;
  36. BOOL ShowBLine = FALSE, DataChanged, AutoHeight = FALSE;
  37. BOOL InvertShift = FALSE, Toggle = TRUE, QueryWidth = FALSE;
  38.  
  39. struct Preferences Prefs;
  40. struct TextAttr ScrFontAttr, FixFontAttr;
  41. char ScrFontAttrName[MAXFONTNAME], FixFontAttrName[MAXFONTNAME];
  42. struct NewMenu Menus[] = { PROJECT_MENU,FONT_MENU,End };
  43. struct NewMenu CharMenus[] = { PROJECT_MENU,FONT_MENU,CHARACTER_MENU,End };
  44. struct IBox Box = { 0,0,0,0 };
  45. char Version[] = "$VER: "NAME" "VERSION" (1.6.96)";
  46.  
  47. struct Window *ParamWnd;
  48. Object *ParamWndObj, *PropCycle, *HeightInt, *WidthInt, *BaseInt, *SmearInt;
  49. Object *NormalCheck, *BoldCheck, *ItalicCheck, *UnderCheck;
  50. Object *ExtCheck, *RevCheck, *AspectCycle, *BlankButton;
  51. ULONG Proportional, Normal, Bold, Italic, ULine, Extended, Reversed;
  52. ULONG Height, Width, Baseline, Smear, Aspect;
  53. STRPTR PropLabels[3], AspectLabels[4], SaveLabels[3];
  54.  
  55. struct Window *PrefsWnd;
  56. Object *PrefsWndObj;
  57. Object *CustButton, *ModeButton, *ModeInfo, *FontButton, *FontInfo, *PubStr;
  58. Object *VecInt, *PixelXInt, *PixelYInt, *PixelCycle, *SizeCheck, *ChrHInt;
  59. Object *SaveCycle, *ChrWCycle, *ChrFontInfo, *ChrFontButton, *MaxCheck;
  60. Object *QuitCheck, *BLineCheck, *AutoCheck, *ShiftCheck, *ToggleCheck;
  61. Object *QueryCheck;
  62. Object *ToolBarOut, *ToolBarIn;
  63. char PrefScrBuffer[256];
  64. ULONG PrefScrModeID,PrefScrDepth;
  65. char PrefScrFontName[MAXFONTNAME];
  66. UWORD PrefScrFontHeight;
  67. char PrefThisPubName[MAXPUBSCREENNAME], PrefDefPubName[MAXPUBSCREENNAME];
  68. extern ULONG PixelBorder;
  69. char PrefFixFontName[MAXFONTNAME];
  70. UWORD PrefFixFontHeight;
  71. char PrefFixBuffer[256];
  72. STRPTR PrefsPages[6], BorderLabels[4];
  73. struct Hook *TBDisplayHook, *TBResourceHook, *TBCompareHook;
  74.  
  75. struct Window *AssignWnd;
  76. Object *AssignWndObj, *FontDirStr, *DirReqObj, *SaveReqObj;
  77.  
  78. struct Window *EditCharWnd;
  79. Object *EditCharWndObj, *EditCharNum;
  80.  
  81. struct Window *WidthWnd;
  82. struct Character *WidthChar;
  83. struct CharNode *WidthNode;
  84. Object *WidthWndObj, *ChrWidthScroll, *ChrWidthInt, *LeftInd, *RightInd;
  85. char WidthTitle[256];
  86.  
  87. struct Window *KernWnd;
  88. struct Character *KernChar;
  89. struct CharNode *KernNode;
  90. Object *KernWndObj, *SpaceObj, *KernObj;
  91. char KernTitle[256];
  92.  
  93. struct Window *SaveWnd;
  94. Object *SaveWndObj, *SaveDirStr, *FontNameStr, *SizeInfo;
  95. Object *FirstNum, *LastNum, *TableCheck;
  96.  
  97. extern struct Window *ResetKernWnd;
  98. extern Object *ResetKernWndObj, *ResetSpaceInt, *ResetKernInt;
  99.  
  100. extern struct Window *QueryWnd;
  101. extern Object *QueryWndObj, *QueryWidthNum;
  102.  
  103. extern struct Window *PreviewWnd;
  104. extern Object *PreviewWndObj;
  105.  
  106. main()
  107. {
  108.   Setup();
  109.   MsgLoop();
  110. }
  111.  
  112. wbmain()
  113. {
  114.   main();
  115. }
  116.  
  117. void Setup(void)
  118. {
  119. struct Screen *defscr;
  120. static struct TextAttr topaz8 = { "topaz.font",8,FS_NORMAL,FPF_ROMFONT };
  121. BPTR lock;
  122.  
  123.   if (IntuitionBase->LibNode.lib_Version < 37) Quit();
  124.   if ((AslBase = OpenLibrary("asl.library",37)) == NULL)
  125.     Error(GetString(msgNoAslLib));
  126.   if ((DiskfontBase = OpenLibrary("diskfont.library",36)) == NULL)
  127.     Error(GetString(msgNoDiskfontLib));
  128.   if ((IFFParseBase = OpenLibrary("iffparse.library",37)) == NULL)
  129.     Error(GetString(msgNoIFFParseLib));
  130.   if ((KeymapBase = OpenLibrary("keymap.library",37)) == NULL) Quit();
  131.   if ((BGUIBase = OpenLibrary("bgui.library",40)) == NULL)
  132.   {
  133.     if ((BGUIBase = OpenLibrary("PROGDIR:libs/bgui.library",40)) == NULL)
  134.       Error(GetString(msgNoBguiLib));
  135.   }
  136.   if ((TextFieldBase = OpenLibrary("gadgets/textfield.gadget",3)) == NULL)
  137.   {
  138.     if ((TextFieldBase = OpenLibrary("PROGDIR:gadgets/textfield.gadget",3))
  139.       == NULL) Error(GetString(msgNoTextFieldGadget));
  140.   }
  141.   if ((FontReq = AllocAslRequestTags(ASL_FontRequest,
  142.     ASLFO_TitleText,GetString(msgOpenFont),
  143.     ASLFO_MaxHeight,1000,TAG_DONE)) == NULL) ErrorCode(ASLALLOC);
  144.   if ((PrefsFontReq = AllocAslRequestTags(ASL_FontRequest,
  145.     ASLFO_TitleText,GetString(msgScreenFont),
  146.     ASLFO_MaxHeight,1000,TAG_DONE)) == NULL) ErrorCode(ASLALLOC);
  147.   if (AslBase->lib_Version > 37)
  148.   {
  149.     if ((PrefsScrReq = AllocAslRequestTags(ASL_ScreenModeRequest,
  150.       ASLSM_TitleText,GetString(msgScreenMode),
  151.       ASLSM_DoDepth,TRUE,TAG_DONE)) == NULL) ErrorCode(ASLALLOC);
  152.   }
  153.   if ((CharClass = InitCharGadgClass()) == NULL) Quit();
  154.   if ((EditClass = InitEditGadgClass()) == NULL) Quit();
  155.   if ((SlideClass = InitSlideGadgClass()) == NULL) Quit();
  156.   if ((LVClass = InitFLClass()) == NULL) Quit();
  157.   if (GetNewList(&CharWndList) == NULL) Quit();
  158.   if ((WndMsgPort = CreateMsgPort()) == NULL) ErrorCode(CREATEPORT);
  159.  
  160. int i;
  161.  
  162.   if ((KeyLabelTable = AllocVec(512,MEMF_CLEAR)) == NULL)
  163.     ErrorCode(ALLOCVEC);
  164.   for (i = 0; i < 256; i++) *(KeyLabelTable+(i*2)) = i;
  165.  
  166.   strcpy(Prefs.ThisPubName,NAME);
  167.   GetDefaultPubScreen(Prefs.DefPubName);
  168.   if ((defscr = LockPubScreen(Prefs.DefPubName)) == NULL)
  169.     ErrorCode(LOCKSCREEN);
  170.   Prefs.Version = CURRENT_PREFS;
  171.   Prefs.Flags = PREFS_CUSTOMSCREEN|PREFS_PIXELBORDER;
  172.   Prefs.ScrModeID = GetVPModeID(&defscr->ViewPort);
  173.   Prefs.ScrDepth = 2;
  174.   Prefs.VecHeight = 11;
  175.   Prefs.PixelX = 20;
  176.   Prefs.PixelY = 20;
  177.   strcpy(Prefs.ScrFontName,defscr->Font->ta_Name);
  178.   Prefs.ScrFontHeight = defscr->Font->ta_YSize;
  179.   strcpy(Prefs.FixedFontName,
  180.     GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name);
  181.   Prefs.FixedFontHeight = GfxBase->DefaultFont->tf_YSize;
  182.   Prefs.ToolBar = DEFAULT_TBAR;
  183.   Prefs.CharSize = FALSE;
  184.   Prefs.CharWidth = 1;
  185.   Prefs.CharHeight = 8;
  186.   UnlockPubScreen(NULL,defscr);
  187.  
  188.   if ((FontWndHook = AllocVec(sizeof(struct Hook),MEMF_CLEAR)) == NULL)
  189.     ErrorCode(ALLOCVEC);
  190.   FontWndHook->h_Entry = (HOOKFUNC)WindowHook;
  191.  
  192.   LoadPrefs();
  193.   SetupScreen();
  194.   strcpy(FontPath,"FONTS:");
  195.   if (lock = Lock("FONTS:",ACCESS_READ))
  196.   {
  197.     NameFromLock(lock,FontPath,256);
  198.     UnLock(lock);
  199.   }
  200.   strcpy(SavePath,FontPath);
  201.   LoadFont(&topaz8,0);
  202. }
  203.  
  204. void SetupScreen(void)
  205. {
  206. UWORD pens[] = { ~0 };
  207. struct Screen *pubscr;
  208. BOOL unique_pub_name = TRUE;
  209.  
  210.   if (CustomScreen)
  211.   {
  212.     strcpy(ScrFontAttrName,Prefs.ScrFontName);
  213.     ScrFontAttr.ta_Name = ScrFontAttrName;
  214.     ScrFontAttr.ta_YSize = Prefs.ScrFontHeight;
  215.     ScrFontAttr.ta_Style = FS_NORMAL;
  216.     ScrFont = OpenDiskFont(&ScrFontAttr);
  217.  
  218.     if ((pubscr = LockPubScreen(Prefs.ThisPubName)) != NULL)
  219.     {
  220.       UnlockPubScreen(NULL,pubscr);
  221.       unique_pub_name = FALSE;
  222.     }
  223.  
  224.     if ((Screen = OpenScreenTags(NULL,
  225.       SA_Depth,Prefs.ScrDepth,
  226.       SA_DisplayID,Prefs.ScrModeID,
  227.       unique_pub_name ? SA_PubName : TAG_IGNORE,Prefs.ThisPubName,
  228.       SA_Pens,pens,
  229.       SA_Font,&ScrFontAttr,
  230. #ifdef BETA
  231.       SA_Title,NAME" BETA",
  232. #else
  233.       SA_Title,NAME,
  234. #endif
  235.       SA_AutoScroll,TRUE,
  236.       TAG_DONE)) == NULL) ErrorCode(OPENSCREEN);
  237.     PubScreenStatus(Screen,0);
  238.   }
  239.   else
  240.   {
  241.     if ((Screen = LockPubScreen(Prefs.DefPubName)) == NULL)
  242.     {
  243.       if ((Screen = LockPubScreen(NULL)) == NULL)
  244.     ErrorCode(LOCKSCREEN);
  245.     }
  246.   }
  247.   GetScreenRatio(Screen);
  248.  
  249.   if ((ScrDrawInfo = GetScreenDrawInfo(Screen)) == NULL) Quit();
  250.   SizeImage = (struct Image *)CreateSysImage(SIZEIMAGE,ScrDrawInfo);
  251.   LeftImage = (struct Image *)CreateSysImage(LEFTIMAGE,ScrDrawInfo);
  252.   RightImage = (struct Image *)CreateSysImage(RIGHTIMAGE,ScrDrawInfo);
  253.   UpImage = (struct Image *)CreateSysImage(UPIMAGE,ScrDrawInfo);
  254.   DownImage = (struct Image *)CreateSysImage(DOWNIMAGE,ScrDrawInfo);
  255.   Box.Top = Screen->BarHeight+1;
  256.   if (AutoHeight) Prefs.VecHeight = SizeY(11);
  257.   OpenFontWnd();
  258.   ScreenToFront(Screen);
  259. }
  260.  
  261. __geta4 ULONG WindowHook(__a0 struct Hook *hook, __a2 Object *o,
  262.   __a1 struct IntuiMessage *msg)
  263. {
  264. Object *charobj;
  265. ULONG height,pos;
  266. struct IBox newp;
  267.  
  268.   if ((msg->Class == IDCMP_CHANGEWINDOW) && (msg->Code == CWCODE_MOVESIZE))
  269.   {
  270.     GetAttr(EXT_Object,CharObj,(ULONG *)&charobj);
  271.     GetAttr(WINDOW_Bounds,FontWndObj,(ULONG *)&newp);
  272.     if ((newp.Width != FontSize.Width) || (newp.Height != FontSize.Height))
  273.     {
  274.       height = (FontWnd->Height-FontWnd->BorderTop-FontWnd->BorderBottom-
  275.     (2*SizeY(2)))/GetCharGadgHeight(1,FixFont);
  276.       GetAttr(CG_Pos,charobj,&pos);
  277.       SetGadgetAttrs((struct Gadget *)ScrollObj,FontWnd,NULL,
  278.     PGA_Top,pos,
  279.     PGA_Total,256/(4<<Prefs.CharWidth),
  280.     PGA_Visible,height,TAG_DONE);
  281.       GetAttr(PGA_Top,ScrollObj,&pos);
  282.       SetGadgetAttrs((struct Gadget *)charobj,FontWnd,NULL,
  283.     CG_Pos,pos,
  284.     CG_SizeY,height,
  285.     CG_Redraw,TRUE,TAG_DONE);
  286.     }
  287.     GetAttr(WINDOW_Bounds,FontWndObj,(ULONG *)&FontSize);
  288.   }
  289.   return 0;
  290. }
  291.  
  292. void OpenFontWnd(void)
  293. {
  294. ULONG height;
  295.  
  296.   strcpy(FixFontAttrName,Prefs.FixedFontName);
  297.   FixFontAttr.ta_Name = FixFontAttrName;
  298.   FixFontAttr.ta_YSize = Prefs.FixedFontHeight;
  299.   FixFontAttr.ta_Style = FS_NORMAL;
  300.   FixFont = OpenDiskFont(&FixFontAttr);
  301.  
  302.   height = Prefs.CharHeight+1;
  303.   do
  304.   {
  305.     height--;
  306.     Box.Height = GetCharGadgHeight(height,FixFont)+(2*SizeY(2))+
  307.       Screen->WBorTop+1+Screen->Font->ta_YSize+
  308.       (Prefs.CharSize ? SizeImage->Height : Screen->WBorBottom);
  309.   } while (Box.Height > Screen->Height);
  310.  
  311.   SetupMenus(Menus);
  312.   FontWndObj = WindowObject,
  313.     WINDOW_Screen,Screen,
  314.     WINDOW_SharedPort,WndMsgPort,
  315.     WINDOW_IDCMPHook,FontWndHook,
  316.     WINDOW_IDCMPHookBits,IDCMP_CHANGEWINDOW,
  317.     WINDOW_MenuStrip,Menus,
  318.     WINDOW_Bounds,&Box,
  319.     WINDOW_HelpFile,NAME".guide",
  320.     WINDOW_SmartRefresh,TRUE,
  321.     WINDOW_NoBufferRP,TRUE,
  322.     WINDOW_SizeGadget,Prefs.CharSize,
  323.     WINDOW_Title,WinTitle,
  324.     WINDOW_MasterGroup,
  325.       HGroupObject,
  326.     HOffset(SizeX(4)),VOffset(SizeY(2)),Spacing(SizeX(2)),
  327.     StartMember,
  328.       CharObj = ExternalObject,
  329.         EXT_MinWidth,GetCharGadgWidth(4<<Prefs.CharWidth,FixFont)-2,
  330.         EXT_MinHeight,GetCharGadgHeight(2,FixFont)-2,
  331.         EXT_Class,CharClass,
  332.         EXT_NoRebuild,TRUE,
  333.         CG_Font,FixFont ? FixFont : GfxBase->DefaultFont,
  334.         CG_SizeX,4<<Prefs.CharWidth,
  335.         CG_SizeY,height,
  336.         GA_ID,ID_CHARS,
  337.       EndObject,
  338.     EndMember,
  339.     StartMember,
  340.       ScrollObj = PropObject,
  341.         PGA_Top,0,
  342.         PGA_Total,256/(4<<Prefs.CharWidth),
  343.         PGA_Visible,height,
  344.         PGA_Arrows,TRUE,
  345.         GA_ID,ID_CHARSCROLL,
  346.       EndObject,
  347.       FixMinWidth,
  348.     EndMember,
  349.       EndObject,
  350.     EndObject;
  351.   if (FontWndObj == NULL) ErrorCode(NEWWINDOW);
  352.   if ((FontWnd = WindowOpen(FontWndObj)) == NULL)
  353.   {
  354.     if (Prefs.CharWidth > 0)
  355.     {
  356.       CloseFontWnd();
  357.       Prefs.CharWidth--;
  358.       OpenFontWnd();
  359.     }
  360.     else ErrorCode(OPENWINDOW);
  361.   }
  362.   FontWnd->MaxWidth = FontWnd->Width;
  363.   FontWnd->MaxHeight = GetCharGadgHeight(256/(4<<Prefs.CharWidth),FixFont)+
  364.     FontWnd->BorderTop+FontWnd->BorderBottom+(2*SizeY(2));
  365.   OldWindowPtr = ((struct Process *)FindTask(NULL))->pr_WindowPtr;
  366.   ((struct Process *)FindTask(NULL))->pr_WindowPtr = FontWnd;
  367.   GetAttr(WINDOW_Bounds,FontWndObj,(ULONG *)&CharSize);
  368.   CharSize.Left += (CharSize.Width + Screen->RastPort.Font->tf_YSize);
  369.   CharSize.Width = Screen->Width - CharSize.Left;
  370.   CharSize.Height = Screen->Height - CharSize.Top;
  371.   GetAttr(WINDOW_Bounds,FontWndObj,(ULONG *)&FontSize);
  372. }
  373.  
  374. void CloseFontWnd(void)
  375. {
  376.   ClrWindowClose(&FontWndObj,&FontWnd);
  377.   ClrDisposeObject(&FontWndObj);
  378.   if (FixFont)
  379.   {
  380.     CloseFont(FixFont);
  381.     FixFont = NULL;
  382.   }
  383. }
  384.  
  385. void Quit(void)
  386. {
  387.   QuitScreen();
  388.   RemoveList(&CharWndList,TRUE,NULL);
  389.   ClearCurrentFont();
  390.   if (ClipChar.chr_Data) FreeVec(ClipChar.chr_Data);
  391.   if (NewFont) CloseFont(NewFont);
  392.   if (WndMsgPort) DeleteMsgPort(WndMsgPort);
  393.   if (SlideClass) FreeEditGadgClass(SlideClass);
  394.   if (EditClass) FreeEditGadgClass(EditClass);
  395.   if (CharClass) FreeCharGadgClass(CharClass);
  396.   if (LVClass) FreeFLClass(LVClass);
  397.   if (PrefsScrReq) FreeAslRequest(PrefsScrReq);
  398.   if (PrefsFontReq) FreeAslRequest(PrefsFontReq);
  399.   if (FontReq) FreeAslRequest(FontReq);
  400.   if (FontWndHook) FreeVec(FontWndHook);
  401.   if (KeyLabelTable) FreeVec(KeyLabelTable);
  402.   if (BGUIBase) CloseLibrary(BGUIBase);
  403.   if (TextFieldBase) CloseLibrary(TextFieldBase);
  404.   if (IFFParseBase) CloseLibrary(IFFParseBase);
  405.   if (KeymapBase) CloseLibrary(KeymapBase);
  406.   if (DiskfontBase) CloseLibrary(DiskfontBase);
  407.   if (AslBase) CloseLibrary(AslBase);
  408.   exit(0);
  409. }
  410.  
  411. void QuitScreen(void)
  412. {
  413.   WakeWindows();
  414.   RemoveList(&CharWndList,FALSE,(HOOKFUNC)CloseCharWin);
  415.   if (FontWnd)
  416.     ((struct Process *)FindTask(NULL))->pr_WindowPtr = OldWindowPtr;
  417.   CloseFontWnd();
  418.   CloseEditFontWnd(TRUE);
  419.   ClosePrefsWnd(TRUE);
  420.   CloseAssignWnd(TRUE);
  421.   CloseResetKernWnd(TRUE);
  422.   CloseEditCharWnd(TRUE);
  423.   CloseWidthWnd(TRUE);
  424.   CloseKernWnd(TRUE);
  425.   CloseSaveWnd();
  426.   CloseQueryWidthWnd();
  427.   ClosePreviewWnd(TRUE);
  428.   ClrDisposeObject((Object **)&DirReqObj);
  429.   ClrDisposeObject((Object **)&SaveReqObj);
  430.   ClrDisposeObject((Object **)&SizeImage);
  431.   ClrDisposeObject((Object **)&LeftImage);
  432.   ClrDisposeObject((Object **)&RightImage);
  433.   ClrDisposeObject((Object **)&UpImage);
  434.   ClrDisposeObject((Object **)&DownImage);
  435.   if (ScrDrawInfo)
  436.   {
  437.     FreeScreenDrawInfo(Screen,ScrDrawInfo); ScrDrawInfo = NULL;
  438.   }
  439.   if (Screen)
  440.   {
  441.     if (CustomScreen)
  442.     {
  443.       PubScreenStatus(Screen,PSNF_PRIVATE);
  444.       while (CloseScreen(Screen) == FALSE) WarnVisitors();
  445.       if (ScrFont)
  446.       {
  447.     CloseFont(ScrFont); ScrFont = NULL;
  448.       }
  449.     }
  450.     else UnlockPubScreen(NULL,Screen);
  451.     Screen = NULL;
  452.   }
  453. }
  454.  
  455. void MsgLoop(void)
  456. {
  457. ULONG signal,winsig,code,scroll_pos,pressed,old_height,left,first,last;
  458. ULONG old_bline,shift;
  459. UWORD tb_entry;
  460. LONG temp,normal,height;
  461. BOOL free_node,redraw = FALSE;
  462. struct CharNode *node,*oldnode;
  463. Object *charobj;
  464. char *fontstr;
  465. BPTR lock;
  466.  
  467.   GetAttr(WINDOW_SigMask,FontWndObj,&winsig);
  468.   GetAttr(EXT_Object,CharObj,(ULONG *)&charobj);
  469.   while (TRUE)
  470.   {
  471.     signal = Wait(winsig|SIGBREAKF_CTRL_C);
  472.     if (signal & SIGBREAKF_CTRL_C) Quit();
  473.     if (signal & winsig)
  474.     {
  475.       while ((code = CheckObjMsg(FontWnd,FontWndObj)) != WMHI_NOMORE)
  476.       {
  477.     switch (code)
  478.     {
  479.       case WMHI_CLOSEWINDOW:
  480.         CheckQuit();
  481.         break;
  482.       case ID_CHARSCROLL:
  483.         GetAttr(CG_Pos,charobj,&temp);
  484.         GetAttr(PGA_TOP,ScrollObj,&scroll_pos);
  485.         if (temp != scroll_pos)
  486.           SetGadgetAttrs((struct Gadget *)charobj,FontWnd,NULL,
  487.         CG_Pos,scroll_pos,
  488.         CG_Redraw,FALSE,TAG_DONE);
  489.         break;
  490.       case ID_CHARS:
  491.         GetAttr(CG_Pressed,charobj,&pressed);
  492.         SetGadgetAttrs((struct Gadget *)charobj,FontWnd,NULL,
  493.           CG_Pressed,~0,TAG_DONE);
  494.         GetAttr(CG_ShiftDown,charobj,&shift);
  495.         if (InvertShift) shift = !shift;
  496.         if (pressed != ~0) CheckOpenCharWin(pressed,shift);
  497.         break;
  498.       default:
  499.         SharedMsgs(code,NULL);
  500.         break;
  501.     }
  502.       }
  503.       while ((code = CheckObjMsg(ParamWnd,ParamWndObj)) != WMHI_NOMORE)
  504.       {
  505.     switch (code)
  506.     {
  507.       case WMHI_CLOSEWINDOW:
  508.       case ID_CANCEL:
  509.         CloseEditFontWnd(FALSE);
  510.         break;
  511.       case ID_BOLD:
  512.       case ID_ITALIC:
  513.       case ID_ULINE:
  514.       case ID_EXTEND:
  515.         GetAttr(GA_Selected,BoldCheck,&normal);
  516.         GetAttr(GA_Selected,ItalicCheck,&temp);
  517.         normal |= temp;
  518.         GetAttr(GA_Selected,UnderCheck,&temp);
  519.         normal |= temp;
  520.         GetAttr(GA_Selected,ExtCheck,&temp);
  521.         normal |= temp;
  522.         SetGadgetAttrs((struct Gadget *)NormalCheck,ParamWnd,NULL,
  523.           GA_Selected,normal == 0,TAG_DONE);
  524.         break;
  525.       case ID_NORMAL:
  526.         SetGadgetAttrs((struct Gadget *)BoldCheck,ParamWnd,NULL,
  527.           GA_Selected,FALSE,TAG_DONE);
  528.         SetGadgetAttrs((struct Gadget *)ItalicCheck,ParamWnd,NULL,
  529.           GA_Selected,FALSE,TAG_DONE);
  530.         SetGadgetAttrs((struct Gadget *)UnderCheck,ParamWnd,NULL,
  531.           GA_Selected,FALSE,TAG_DONE);
  532.         SetGadgetAttrs((struct Gadget *)ExtCheck,ParamWnd,NULL,
  533.           GA_Selected,FALSE,TAG_DONE);
  534.         break;
  535.       case ID_BLANK:
  536.         CheckOpenCharWin(256,0);
  537.         break;
  538.       case ID_ACCEPT:
  539.         FlagError = FALSE;
  540.         GetAttr(GA_Selected,NormalCheck,&Normal);
  541.         GetAttr(GA_Selected,BoldCheck,&Bold);
  542.         GetAttr(GA_Selected,ItalicCheck,&Italic);
  543.         GetAttr(GA_Selected,UnderCheck,&ULine);
  544.         GetAttr(GA_Selected,ExtCheck,&Extended);
  545.         GetAttr(GA_Selected,RevCheck,&Reversed);
  546.         GetAttr(CYC_Active,AspectCycle,&Aspect);
  547.  
  548.         GetAttr(STRINGA_LongVal,SmearInt,&temp);
  549.         PutPositive(ParamWnd,GetString(msgBoldSmear),temp,0,&Smear);
  550.  
  551.         GetAttr(STRINGA_LongVal,HeightInt,&temp);
  552.         old_height = Height;
  553.         PutPositive(ParamWnd,GetString(msgFontHeight),temp,1,&Height);
  554.         if (old_height != Height)
  555.         {
  556.           redraw = TRUE;
  557.           NewHeights();
  558.         }
  559.  
  560.         old_bline = Baseline;
  561.         GetAttr(STRINGA_LongVal,BaseInt,&temp);
  562.         if (temp >= (LONG)Height)
  563.         {
  564.           if (redraw)
  565.           {
  566.         Baseline = Height-1;
  567.           }
  568.           else
  569.           {
  570.         ShowReq(GetString(msgErrorBaseline),GetString(msgContinue));
  571.         FlagError = TRUE;
  572.           }
  573.         }
  574.         else PutPositive(ParamWnd,GetString(msgFontBaseline),temp,0,
  575.           &Baseline);
  576.         if (old_bline != Baseline) redraw = TRUE;
  577.  
  578.         GetAttr(CYC_Active,PropCycle,&temp);
  579.         if (temp != Proportional)
  580.         {
  581.           if ((Proportional = temp) == FALSE)
  582.           {
  583.         if (ShowReq(GetString(msgWarnPropChange),
  584.           GetString(msgYesNo)) != 0)
  585.         {
  586.           redraw = TRUE;
  587.           NewWidths();
  588.         }
  589.           }
  590.         }
  591.  
  592.         GetAttr(STRINGA_LongVal,WidthInt,&temp);
  593.         if (temp >= 0)
  594.         {
  595.           if (temp != Width)
  596.           {
  597.         Width = temp;
  598.         if (Proportional == FALSE)
  599.         {
  600.           redraw = TRUE;
  601.           NewWidths();
  602.         }
  603.           }
  604.         }
  605.         else
  606.         {
  607.           ShowReq(GetString(msgErrorFontWidth),GetString(msgContinue));
  608.           FlagError = TRUE;
  609.         }
  610.  
  611.         if (FlagError == FALSE) CloseEditFontWnd(FALSE);
  612.         if (redraw == TRUE)
  613.         {
  614.           RedrawAll();
  615.           redraw = FALSE;
  616.         }
  617.         break;
  618.       default:
  619.         SharedMsgs(code,NULL);
  620.         break;
  621.     }
  622.       }
  623.       while ((code = CheckObjMsg(PrefsWnd,PrefsWndObj)) != WMHI_NOMORE)
  624.       {
  625.     switch (code)
  626.     {
  627.       case WMHI_CLOSEWINDOW:
  628.       case ID_CANCEL:
  629.         ClosePrefsWnd(FALSE);
  630.         break;
  631.       case ID_CUSTOM:
  632.         GetAttr(GA_Selected,CustButton,&temp);
  633.         SetGadgetAttrs((struct Gadget *)ModeButton,PrefsWnd,NULL,
  634.           GA_Disabled,(temp != FALSE) ? FALSE : TRUE,TAG_DONE);
  635.         SetGadgetAttrs((struct Gadget *)FontButton,PrefsWnd,NULL,
  636.           GA_Disabled,(temp != FALSE) ? FALSE : TRUE,TAG_DONE);
  637.         SetGadgetAttrs((struct Gadget *)PubStr,PrefsWnd,NULL,
  638.           STRINGA_TextVal,GetPubName(temp),TAG_DONE);
  639.         break;
  640.       case ID_CHOOSEMODE:
  641.         SleepWindows();
  642.         if (AslBase->lib_Version > 37)
  643.         {
  644.           if (AslRequestTags(PrefsScrReq,
  645.         ASLSM_Window,PrefsWnd,
  646.         ASLSM_InitialDisplayID,PrefScrModeID,
  647.         ASLSM_InitialDisplayDepth,PrefScrDepth,TAG_DONE))
  648.           {
  649.         PrefScrModeID = PrefsScrReq->sm_DisplayID;
  650.         PrefScrDepth = PrefsScrReq->sm_DisplayDepth;
  651.         GetDisplayInfoData(NULL,(UBYTE *)&ModeIDName,
  652.           sizeof(struct NameInfo),DTAG_NAME,PrefScrModeID);
  653.         SetGadgetAttrs((struct Gadget *)ModeInfo,PrefsWnd,NULL,
  654.           INFO_TextFormat,ModeIDName.Name,TAG_DONE);
  655.           }
  656.         }
  657.         else ShowReq(GetString(msgNeedAslV38),GetString(msgCancel));
  658.         WakeWindows();
  659.         break;
  660.       case ID_CHOOSEFONT:
  661.         SleepWindows();
  662.         if (AslRequestTags(PrefsFontReq,
  663.           ASLFO_Window,PrefsWnd,
  664.           ASLFO_InitialName,PrefScrFontName,
  665.           ASLFO_InitialSize,PrefScrFontHeight,
  666.           ASLFO_FixedWidthOnly,FALSE,TAG_DONE))
  667.         {
  668.           strcpy(PrefScrFontName,PrefsFontReq->fo_Attr.ta_Name);
  669.           PrefScrFontHeight = PrefsFontReq->fo_Attr.ta_YSize;
  670.           WriteFont(PrefScrBuffer,PrefScrFontName,PrefScrFontHeight);
  671.           SetGadgetAttrs((struct Gadget *)FontInfo,PrefsWnd,NULL,
  672.         INFO_TextFormat,PrefScrBuffer,TAG_DONE);
  673.         }
  674.         WakeWindows();
  675.         break;
  676.       case ID_CHOOSEFIXFONT:
  677.         SleepWindows();
  678.         if (AslRequestTags(PrefsFontReq,
  679.           ASLFO_Window,PrefsWnd,
  680.           ASLFO_InitialName,PrefFixFontName,
  681.           ASLFO_InitialSize,PrefFixFontHeight,
  682.           ASLFO_FixedWidthOnly,TRUE,TAG_DONE))
  683.         {
  684.           strcpy(PrefFixFontName,PrefsFontReq->fo_Attr.ta_Name);
  685.           PrefFixFontHeight = PrefsFontReq->fo_Attr.ta_YSize;
  686.           WriteFont(PrefFixBuffer,PrefFixFontName,PrefFixFontHeight);
  687.           SetGadgetAttrs((struct Gadget *)ChrFontInfo,PrefsWnd,NULL,
  688.         INFO_TextFormat,PrefFixBuffer,TAG_DONE);
  689.         }
  690.         WakeWindows();
  691.         break;
  692.       case ID_PUBNAME:
  693.         CopyPubName();
  694.         break;
  695.       case ID_AUTOHEIGHT:
  696.         GetAttr(GA_Selected,AutoCheck,&temp);
  697.         SetGadgetAttrs((struct Gadget *)VecInt,PrefsWnd,NULL,
  698.           GA_Disabled,temp,TAG_DONE);
  699.         break;
  700.       case ID_ACCEPT:
  701.       case ID_USE:
  702.         FlagError = FALSE;
  703.         NewCustom = CustomScreen;
  704.         NewWindow = FALSE;
  705.         GetAttr(GA_Selected,CustButton,&temp);
  706.  
  707.         if ((temp == 0) != (CustomScreen == 0))
  708.         {
  709.           ChangeScreen = TRUE;
  710.           NewCustom = (CustomScreen == TRUE) ? FALSE : TRUE;
  711.         }
  712.  
  713.         if (temp != FALSE)
  714.         {
  715.           if ((PrefScrModeID != Prefs.ScrModeID) ||
  716.         (PrefScrDepth != Prefs.ScrDepth))
  717.           {
  718.         ChangeScreen = TRUE;
  719.         NewCustom = TRUE;
  720.           }
  721.         }
  722.         Prefs.ScrModeID = PrefScrModeID;
  723.         Prefs.ScrDepth = PrefScrDepth;
  724.  
  725.         if (temp != FALSE)
  726.         {
  727.           if ((stricmp(PrefScrFontName,Prefs.ScrFontName) != 0) ||
  728.         (PrefScrFontHeight != Prefs.ScrFontHeight))
  729.           {
  730.         ChangeScreen = TRUE;
  731.         NewCustom = TRUE;
  732.           }
  733.         }
  734.         strcpy(Prefs.ScrFontName,PrefScrFontName);
  735.         Prefs.ScrFontHeight = PrefScrFontHeight;
  736.  
  737.         CopyPubName();
  738.         if (temp != FALSE)
  739.         {
  740.           if (stricmp(PrefThisPubName,Prefs.ThisPubName) != 0)
  741.           {
  742.         ChangeScreen = TRUE;
  743.             NewCustom = TRUE;
  744.           }
  745.         }
  746.         else
  747.         {
  748.           if (stricmp(PrefDefPubName,Prefs.DefPubName) != 0)
  749.           {
  750.         ChangeScreen = TRUE;
  751.             NewCustom = FALSE;
  752.           }
  753.         }
  754.         strcpy(Prefs.ThisPubName,PrefThisPubName);
  755.         strcpy(Prefs.DefPubName,PrefDefPubName);
  756.  
  757.         GetAttr(STRINGA_LongVal,VecInt,&temp);
  758.         PutPositive(PrefsWnd,GetString(msgToolbarHeight),temp,10,
  759.           &(Prefs.VecHeight));
  760.         Prefs.ToolBar = 0;
  761.         tb_entry = FirstEntry(ToolBarIn);
  762.         while (tb_entry)
  763.         {
  764.           Prefs.ToolBar |= tb_entry;
  765.           tb_entry = NextEntry(ToolBarIn,tb_entry);
  766.         }
  767.         GetAttr(GA_Selected,AutoCheck,&temp);
  768.         AutoHeight = temp ? TRUE : FALSE;
  769.         if (AutoHeight) Prefs.VecHeight = SizeY(11);
  770.  
  771.         GetAttr(STRINGA_LongVal,PixelXInt,&temp);
  772.         PutPositive(PrefsWnd,GetString(msgPixelWidth),temp,1,
  773.           &(Prefs.PixelX));
  774.         GetAttr(STRINGA_LongVal,PixelYInt,&temp);
  775.         PutPositive(PrefsWnd,GetString(msgPixelHeight),temp,1,
  776.           &(Prefs.PixelY));
  777.         GetAttr(CYC_Active,PixelCycle,&PixelBorder);
  778.         GetAttr(GA_Selected,MaxCheck,&temp);
  779.         MaxWindow = temp ? TRUE : FALSE;
  780.         GetAttr(GA_Selected,BLineCheck,&temp);
  781.         ShowBLine = temp ? TRUE : FALSE;
  782.         GetAttr(GA_Selected,ToggleCheck,&temp);
  783.         Toggle = temp ? TRUE : FALSE;
  784.  
  785.         GetAttr(GA_Selected,ShiftCheck,&temp);
  786.         InvertShift = temp ? TRUE : FALSE;
  787.         GetAttr(GA_Selected,SizeCheck,&temp);
  788.         if (Prefs.CharSize != temp)
  789.         {
  790.           Prefs.CharSize = temp;
  791.           NewWindow = TRUE;
  792.         }
  793.         GetAttr(CYC_Active,ChrWCycle,&temp);
  794.         if (Prefs.CharWidth != temp)
  795.         {
  796.           Prefs.CharWidth = temp;
  797.           NewWindow = TRUE;
  798.         }
  799.         GetAttr(STRINGA_LongVal,ChrHInt,&temp);
  800.         height = 0;
  801.         PutPositive(PrefsWnd,GetString(msgSelWndWidth),temp,0,&height);
  802.         if (height > 0)
  803.         {
  804.           if (height*(4<<Prefs.CharWidth) > 256)
  805.         height = 256/(4<<Prefs.CharWidth);
  806.           if (Prefs.CharHeight != height)
  807.           {
  808.         Prefs.CharHeight = height;
  809.         NewWindow = TRUE;
  810.           }
  811.         }
  812.         if ((stricmp(PrefFixFontName,Prefs.FixedFontName) != 0) ||
  813.           (PrefFixFontHeight != Prefs.FixedFontHeight)) NewWindow = TRUE;
  814.         strcpy(Prefs.FixedFontName,PrefFixFontName);
  815.         Prefs.FixedFontHeight = PrefFixFontHeight;
  816.  
  817.         GetAttr(CYC_Active,SaveCycle,&(Prefs.SaveTo));
  818.         GetAttr(GA_Selected,QuitCheck,&temp);
  819.         ConfirmQuit = temp ? TRUE : FALSE;
  820.         GetAttr(GA_Selected,QueryCheck,&temp);
  821.         QueryWidth = temp ? TRUE : FALSE;
  822.  
  823.         if (code == ID_ACCEPT)
  824.         {
  825.           if (Prefs.SaveTo == 0)
  826.           {
  827.         SavePrefs("ENV:"NAME".prefs");
  828.         SavePrefs("ENVARC:"NAME".prefs");
  829.           }
  830.           else SavePrefs("PROGDIR:"NAME".prefs");
  831.         }
  832.         if (FlagError == FALSE) ClosePrefsWnd(FALSE);
  833.         break;
  834.       default:
  835.         SharedMsgs(code,NULL);
  836.         break;
  837.     }
  838.       }
  839.       while ((code = CheckObjMsg(AssignWnd,AssignWndObj)) != WMHI_NOMORE)
  840.       {
  841.     switch (code)
  842.     {
  843.       case WMHI_CLOSEWINDOW:
  844.       case ID_CANCEL:
  845.         CloseAssignWnd(FALSE);
  846.         break;
  847.       case ID_ASSIGN:
  848.       case ID_ASSIGNADD:
  849.         GetAttr(STRINGA_TextVal,FontDirStr,(ULONG *)&fontstr);
  850.         strcpy(FontPath,fontstr);
  851.         SleepWindows();
  852.         if ((lock = Lock(FontPath,ACCESS_READ)) != 0)
  853.         {
  854.           if (code == ID_ASSIGNADD)
  855.         AssignAdd("FONTS",lock);
  856.           else
  857.         AssignLock("FONTS",lock);
  858.           strcpy(SavePath,FontPath);
  859.           FlushAllFonts();
  860.         }
  861.         else ShowReq(GetString(msgNoDir),GetString(msgCancel),FontPath);
  862.         WakeWindows();
  863.         CloseAssignWnd(FALSE);
  864.         break;
  865.       case ID_ASSIGNPATH:
  866.         SleepWindows();
  867.         GetAttr(STRINGA_TextVal,FontDirStr,(ULONG *)&fontstr);
  868.         SetAttrs(DirReqObj,ASLFR_InitialDrawer,fontstr,TAG_DONE);
  869.         if (DoRequest(DirReqObj) == FRQ_OK)
  870.         {
  871.           GetAttr(FRQ_Drawer,DirReqObj,(ULONG *)&fontstr);
  872.           SetGadgetAttrs((struct Gadget *)FontDirStr,AssignWnd,NULL,
  873.         STRINGA_TextVal,fontstr,TAG_DONE);
  874.         }
  875.         WakeWindows();
  876.         break;
  877.       default:
  878.         SharedMsgs(code,NULL);
  879.         break;
  880.     }
  881.       }
  882.       while ((code = CheckObjMsg(ResetKernWnd,ResetKernWndObj)) != WMHI_NOMORE)
  883.       {
  884.     switch (code)
  885.     {
  886.       case WMHI_CLOSEWINDOW:
  887.       case ID_CANCEL:
  888.         CloseResetKernWnd(FALSE);
  889.         break;
  890.       case ID_ACCEPT:
  891.  
  892.       LONG space,kern;
  893.  
  894.         GetAttr(STRINGA_LongVal,ResetSpaceInt,&space);
  895.         GetAttr(STRINGA_LongVal,ResetKernInt,&kern);
  896.         CloseResetKernWnd(FALSE);
  897.         ResetKerning(space,kern);
  898.         break;
  899.       default:
  900.         SharedMsgs(code,NULL);
  901.         break;
  902.     }
  903.       }
  904.       while ((code = CheckObjMsg(EditCharWnd,EditCharWndObj)) != WMHI_NOMORE)
  905.       {
  906.     switch (code)
  907.     {
  908.       case WMHI_CLOSEWINDOW:
  909.       case ID_CANCEL:
  910.         CloseEditCharWnd(FALSE);
  911.         break;
  912.       case ID_ACCEPT:
  913.       case ID_EDITCHARNUM:
  914.         GetAttr(STRINGA_LongVal,EditCharNum,&temp);
  915.         if ((temp >= 0) && (temp < 256))
  916.         {
  917.           CloseEditCharWnd(FALSE);
  918.           CheckOpenCharWin(temp,0);
  919.         }
  920.         else
  921.         {
  922.           DisplayBeep(EditCharWnd->WScreen);
  923.           ActivateGadget((struct Gadget *)EditCharNum,EditCharWnd,NULL);
  924.         }
  925.         break;
  926.       default:
  927.         SharedMsgs(code,NULL);
  928.         break;
  929.     }
  930.       }
  931.       while ((code = CheckObjMsg(QueryWnd,QueryWndObj)) != WMHI_NOMORE)
  932.       {
  933.     switch (code)
  934.     {
  935.       case ID_ACCEPT:
  936.         WakeWindows();
  937.         CloseQueryWidthWnd();
  938.         GetAttr(STRINGA_LongVal,QueryWidthNum,&temp);
  939.         LoadFont(&FontReq->fo_Attr,temp);
  940.         LoadChosenFont();
  941.         break;
  942.     }
  943.       }
  944.       while ((code = CheckObjMsg(PreviewWnd,PreviewWndObj)) != WMHI_NOMORE)
  945.       {
  946.     switch (code)
  947.     {
  948.       case WMHI_CLOSEWINDOW:
  949.       case ID_CANCEL:
  950.         ClosePreviewWnd(FALSE);
  951.         break;
  952.       default:
  953.         PreviewMsgs(code);
  954.         break;
  955.     }
  956.       }
  957.       while ((code = CheckObjMsg(WidthWnd,WidthWndObj)) != WMHI_NOMORE)
  958.       {
  959.     switch (code)
  960.     {
  961.       case WMHI_CLOSEWINDOW:
  962.       case ID_CANCEL:
  963.         CloseWidthWnd(FALSE);
  964.         break;
  965.       case ID_ACCEPT:
  966.         GetAttr(STRINGA_LongVal,ChrWidthInt,&temp);
  967.         GetAttr(PGA_Top,ChrWidthScroll,&left);
  968.         if (temp >= 0)
  969.         {
  970.           if (temp > WidthChar->chr_Width)
  971.         ChangeCharWidth(WidthChar,temp,left,0);
  972.           else
  973.         ChangeCharWidth(WidthChar,temp,0,left);
  974.           RedrawEdit(WidthNode);
  975.           CloseWidthWnd(FALSE);
  976.         }
  977.         else ShowReq(GetString(msgErrorFontWidth),
  978.           GetString(msgContinue));
  979.         break;
  980.       case ID_CHARWIDTH:
  981.         GetAttr(STRINGA_LongVal,ChrWidthInt,&temp);
  982.         if (temp >= 0)
  983.         {
  984.           SetGadgetAttrs((struct Gadget *)ChrWidthScroll,WidthWnd,NULL,
  985.         PGA_Total,MAX(WidthChar->chr_Width,temp),
  986.         PGA_Visible,MIN(WidthChar->chr_Width,temp),TAG_DONE);
  987.         }
  988.         else
  989.         {
  990.           ShowReq(GetString(msgErrorFontWidth),GetString(msgContinue));
  991.           SetGadgetAttrs((struct Gadget *)ChrWidthInt,WidthWnd,NULL,
  992.         STRINGA_LongVal,WidthChar->chr_Width,TAG_DONE);
  993.         }
  994.         break;
  995.       default:
  996.         SharedMsgs(code,WidthNode);
  997.         break;
  998.     }
  999.       }
  1000.       while ((code = CheckObjMsg(KernWnd,KernWndObj)) != WMHI_NOMORE)
  1001.       {
  1002.     switch (code)
  1003.     {
  1004.       case WMHI_CLOSEWINDOW:
  1005.       case ID_CANCEL:
  1006.         CloseKernWnd(FALSE);
  1007.         break;
  1008.       case ID_ACCEPT:
  1009.         GetAttr(STRINGA_LongVal,SpaceObj,&temp);
  1010.         SpaceTable[KernNode->chln_Number] = temp;
  1011.         GetAttr(STRINGA_LongVal,KernObj,&temp);
  1012.         KernTable[KernNode->chln_Number] = temp;
  1013.         CloseKernWnd(FALSE);
  1014.         break;
  1015.       default:
  1016.         SharedMsgs(code,KernNode);
  1017.         break;
  1018.     }
  1019.       }
  1020.       while ((code = CheckObjMsg(SaveWnd,SaveWndObj)) != WMHI_NOMORE)
  1021.       {
  1022.     switch (code)
  1023.     {
  1024.       case WMHI_CLOSEWINDOW:
  1025.       case ID_CANCEL:
  1026.         CloseSaveWnd();
  1027.         break;
  1028.       case ID_ACCEPT:
  1029.         GetAttr(STRINGA_LongVal,FirstNum,&first);
  1030.         if ((first < 0) || (first > 255))
  1031.           SaveShowReq(GetString(msgFirstRange),GetString(msgCancel));
  1032.         else
  1033.         {
  1034.           GetAttr(STRINGA_LongVal,LastNum,&last);
  1035.           if ((last < 0) || (last > 255))
  1036.         SaveShowReq(GetString(msgLastRange),GetString(msgCancel));
  1037.           else
  1038.           {
  1039.         if (first > last) SaveShowReq(GetString(msgFirstGreaterLast),
  1040.           GetString(msgCancel));
  1041.         else
  1042.         {
  1043.           FirstChar = first;
  1044.           LastChar = last;
  1045.           GetAttr(STRINGA_TextVal,SaveDirStr,(ULONG *)&fontstr);
  1046.           strcpy(SavePath,fontstr);
  1047.           GetAttr(STRINGA_TextVal,FontNameStr,(ULONG *)&fontstr);
  1048.           strcpy(FontName,fontstr);
  1049.           GetAttr(GA_Selected,TableCheck,&UseTable);
  1050.           SaveFont(UseTable,FALSE);
  1051.           sprintf(WinTitle,"%s/%ld",FontName,Height);
  1052.           SetAttrs(FontWndObj,WINDOW_Title,WinTitle,TAG_DONE);
  1053.           CloseSaveWnd();
  1054.         }
  1055.           }
  1056.         }
  1057.         break;
  1058.       case ID_GETSAVEDIR:
  1059.         GetAttr(STRINGA_TextVal,SaveDirStr,(ULONG *)&fontstr);
  1060.         SetAttrs(SaveReqObj,
  1061.           ASLFR_Window,SaveWnd,
  1062.           ASLFR_InitialDrawer,fontstr,TAG_DONE);
  1063.         WindowBusy(SaveWndObj);
  1064.         if (DoRequest(SaveReqObj) == FRQ_OK)
  1065.         {
  1066.           GetAttr(FRQ_Drawer,SaveReqObj,(ULONG *)&fontstr);
  1067.           SetGadgetAttrs((struct Gadget *)SaveDirStr,SaveWnd,NULL,
  1068.         STRINGA_TextVal,fontstr,TAG_DONE);
  1069.         }
  1070.         WindowReady(SaveWndObj);
  1071.         break;
  1072.     }
  1073.       }
  1074.       node = (struct CharNode *)CharWndList->lh_Head;
  1075.       while (node->chln_Node.ln_Succ)
  1076.       {
  1077.     free_node = FALSE;
  1078.     while ((code =
  1079.       CheckObjMsg(node->chln_Window,node->chln_Object)) != WMHI_NOMORE)
  1080.     {
  1081.       switch (code)
  1082.       {
  1083.         case WMHI_CLOSEWINDOW:
  1084.           CloseCharWin(node);
  1085.           free_node = TRUE;
  1086.           break;
  1087.         default:
  1088.           SharedMsgs(code,node);
  1089.           break;
  1090.       }
  1091.     }
  1092.     oldnode = node;
  1093.     node = (struct CharNode *)node->chln_Node.ln_Succ;
  1094.     if (free_node)
  1095.     {
  1096.       Remove((struct Node *)oldnode);
  1097.       FreeVec(oldnode);
  1098.     }
  1099.       }
  1100.     }
  1101.     if ((ChangeScreen) && (PrefsWnd == NULL))
  1102.     {
  1103.       QuitScreen();
  1104.       CustomScreen = NewCustom;
  1105.       SetupScreen();
  1106.       SetAttrs(FontWndObj,WINDOW_Title,WinTitle,TAG_DONE);
  1107.       GetAttr(WINDOW_SigMask,FontWndObj,&winsig);
  1108.       GetAttr(EXT_Object,CharObj,(ULONG *)&charobj);
  1109.       ChangeScreen = FALSE;
  1110.       NewWindow = FALSE;
  1111.     }
  1112.     if ((NewWindow) && (PrefsWnd == NULL))
  1113.     {
  1114.       if (FontWnd)
  1115.       {
  1116.     ((struct Process *)FindTask(NULL))->pr_WindowPtr = OldWindowPtr;
  1117.     CloseFontWnd();
  1118.     OpenFontWnd();
  1119.     NewWindow = FALSE;
  1120.       }
  1121.     }
  1122.   }
  1123. }
  1124.  
  1125. ULONG CheckObjMsg(struct Window *wnd, Object *obj)
  1126. {
  1127.   return ((wnd != NULL) ? HandleEvent(obj) : WMHI_NOMORE);
  1128. }
  1129.  
  1130. void CheckOpenCharWin(ULONG pressed, ULONG shift)
  1131. {
  1132. struct CharNode *node;
  1133. struct Character *oldchar;
  1134. BOOL open = FALSE;
  1135.  
  1136.   node = (struct CharNode *)CharWndList->lh_Head;
  1137.   while (node->chln_Node.ln_Succ)
  1138.   {
  1139.     if (pressed == node->chln_Number)
  1140.     {
  1141.       open = TRUE;
  1142.       WindowToFront(node->chln_Window);
  1143.       ActivateWindow(node->chln_Window);
  1144.     }
  1145.     node = (struct CharNode *)node->chln_Node.ln_Succ;
  1146.   }
  1147.   if (open == FALSE)
  1148.   {
  1149.     if (shift != 0)
  1150.     {
  1151.       node = (struct CharNode *)CharWndList->lh_Head;
  1152.       if (node->chln_Node.ln_Succ)
  1153.       {
  1154.     oldchar = node->chln_Character;
  1155.     node->chln_Character = CharBuffer+pressed;
  1156.     node->chln_Number = pressed;
  1157.     SetGadgetAttrs((struct Gadget *)node->chln_EditGadg,
  1158.       node->chln_Window,NULL,
  1159.       EG_CharNode,node,
  1160.       EG_CharStruct,node->chln_Character,TAG_DONE);
  1161.     if (pressed > 0)
  1162.       sprintf(node->chln_Title,GetString(msgCharTitle),
  1163.         (char)pressed,pressed,pressed);
  1164.     else
  1165.       sprintf(node->chln_Title,GetString(msgZeroTitle));
  1166.     RedrawEdit(node);
  1167.     SetAttrs(node->chln_Object,WINDOW_Title,node->chln_Title,TAG_DONE);
  1168.     WindowToFront(node->chln_Window);
  1169.     ActivateWindow(node->chln_Window);
  1170.     if (oldchar == WidthChar) OpenWidthWnd(node);
  1171.     if (oldchar == KernChar) OpenKernWnd(node);
  1172.       }
  1173.       else OpenCharWin(pressed,CharSize);
  1174.     }
  1175.     else OpenCharWin(pressed,CharSize);
  1176.   }
  1177. }
  1178.  
  1179. void SharedMsgs(ULONG code,struct CharNode *node)
  1180. {
  1181.   switch (code)
  1182.   {
  1183.     case ID_OPEN:
  1184.       SleepWindows();
  1185.       if (AslRequestTags(FontReq,ASLFO_Window,FontWnd,TAG_DONE))
  1186.       {
  1187.     if ((LoadFont(&FontReq->fo_Attr,0)) && (QueryWidth))
  1188.     {
  1189.       OpenQueryWidthWnd();
  1190.     }
  1191.     else
  1192.     {
  1193.       WakeWindows();
  1194.       LoadChosenFont();
  1195.     }
  1196.       }
  1197.       else WakeWindows();
  1198.       break;
  1199.     case ID_SAVE:
  1200.       OpenSaveWnd();
  1201.       break;
  1202.     case ID_CHANGEDIR:
  1203.       OpenAssignWnd();
  1204.       break;
  1205.     case ID_PREVIEW:
  1206.       OpenPreviewWnd();
  1207.       break;
  1208.     case ID_EDITFONT:
  1209.       OpenEditFontWnd();
  1210.       break;
  1211.     case ID_EDITCHAR:
  1212.       OpenEditCharWnd();
  1213.       break;
  1214.     case ID_PREFS:
  1215.       OpenPrefsWnd();
  1216.       break;
  1217.     case ID_ABOUT:
  1218.       OpenAboutWnd();
  1219.       break;
  1220.     case ID_QUIT:
  1221.       CheckQuit();
  1222.       break;
  1223.     case ID_WIDTHL:
  1224.       if (node)
  1225.       {
  1226.     if (node->chln_Character->chr_Width > 0)
  1227.     {
  1228.       ChangeCharWidth(node->chln_Character,
  1229.         node->chln_Character->chr_Width-1,0,0);
  1230.       RedrawEdit(node);
  1231.     }
  1232.       }
  1233.       break;
  1234.     case ID_WIDTHR:
  1235.       if (node)
  1236.       {
  1237.     ChangeCharWidth(node->chln_Character,
  1238.       node->chln_Character->chr_Width+1,0,0);
  1239.       RedrawEdit(node);
  1240.       }
  1241.       break;
  1242.     case ID_WIDTHC:
  1243.       if (node) OpenWidthWnd(node);
  1244.       break;
  1245.     case ID_KERNING:
  1246.       if (node) OpenKernWnd(node);
  1247.       break;
  1248.     case ID_MOVEL:
  1249.       if (node) MoveLeft(node,NULL);
  1250.       break;
  1251.     case ID_MOVER:
  1252.       if (node) MoveRight(node,NULL);
  1253.       break;
  1254.     case ID_MOVEU:
  1255.       if (node) MoveUp(node,NULL);
  1256.       break;
  1257.     case ID_MOVED:
  1258.       if (node) MoveDown(node,NULL);
  1259.       break;
  1260.     case ID_FLIPH:
  1261.       if (node) FlipHoriz(node);
  1262.       break;
  1263.     case ID_FLIPV:
  1264.       if (node) FlipVert(node);
  1265.       break;
  1266.     case ID_UNDO:
  1267.       if (node) PasteChar(node,&(node->chln_UndoChar));
  1268.       break;
  1269.     case ID_CUT:
  1270.       if (node)
  1271.       {
  1272.     CopyChar(node,&ClipChar);
  1273.     EraseChar(node);
  1274.       }
  1275.       break;
  1276.     case ID_COPY:
  1277.       if (node) CopyChar(node,&ClipChar);
  1278.       break;
  1279.     case ID_PASTE:
  1280.       if (node) PasteChar(node,&ClipChar);
  1281.       break;
  1282.     case ID_ERASE:
  1283.       if (node) EraseChar(node);
  1284.       break;
  1285.     case ID_MOVEFL:
  1286.       MoveAll(MoveLeft);
  1287.       break;
  1288.     case ID_MOVEFR:
  1289.       MoveAll(MoveRight);
  1290.       break;
  1291.     case ID_MOVEFU:
  1292.       MoveAll(MoveUp);
  1293.       break;
  1294.     case ID_MOVEFD:
  1295.       MoveAll(MoveDown);
  1296.       break;
  1297.     case ID_RESETKERN:
  1298.       OpenResetKernWnd();
  1299.       break;
  1300.     case ID_CASCADE:
  1301.       CascadeWindows();
  1302.       break;
  1303.     case ID_ZOOMIN:
  1304.       if (node) ZoomIn(node);
  1305.       break;
  1306.     case ID_ZOOMOUT:
  1307.       if (node) ZoomOut(node);
  1308.       break;
  1309.   }
  1310. }
  1311.  
  1312. void LoadChosenFont(void)
  1313. {
  1314.   if (ParamWnd)
  1315.   {
  1316.     SetGadgetAttrs((struct Gadget *)PropCycle,ParamWnd,NULL,
  1317.       CYC_Active,Proportional,TAG_DONE);
  1318.     SetGadgetAttrs((struct Gadget *)HeightInt,ParamWnd,NULL,
  1319.       STRINGA_LongVal,Height,TAG_DONE);
  1320.     SetGadgetAttrs((struct Gadget *)WidthInt,ParamWnd,NULL,
  1321.       STRINGA_LongVal,Width,TAG_DONE);
  1322.     SetGadgetAttrs((struct Gadget *)BaseInt,ParamWnd,NULL,
  1323.       STRINGA_LongVal,Baseline,TAG_DONE);
  1324.     SetGadgetAttrs((struct Gadget *)SmearInt,ParamWnd,NULL,
  1325.       STRINGA_LongVal,Smear,TAG_DONE);
  1326.     SetGadgetAttrs((struct Gadget *)NormalCheck,ParamWnd,NULL,
  1327.       GA_Selected,Normal,TAG_DONE);
  1328.     SetGadgetAttrs((struct Gadget *)BoldCheck,ParamWnd,NULL,
  1329.       GA_Selected,Bold,TAG_DONE);
  1330.     SetGadgetAttrs((struct Gadget *)ItalicCheck,ParamWnd,NULL,
  1331.       GA_Selected,Italic,TAG_DONE);
  1332.     SetGadgetAttrs((struct Gadget *)UnderCheck,ParamWnd,NULL,
  1333.       GA_Selected,ULine,TAG_DONE);
  1334.     SetGadgetAttrs((struct Gadget *)ExtCheck,ParamWnd,NULL,
  1335.       GA_Selected,Extended,TAG_DONE);
  1336.     SetGadgetAttrs((struct Gadget *)RevCheck,ParamWnd,NULL,
  1337.       GA_Selected,Reversed,TAG_DONE);
  1338.     SetGadgetAttrs((struct Gadget *)AspectCycle,ParamWnd,NULL,
  1339.       CYC_Active,Aspect,TAG_DONE);
  1340.   }
  1341.   RedrawAll();
  1342. }
  1343.  
  1344. void Error(char *message)
  1345. {
  1346.   ShowReq(message,GetString(msgCancel));
  1347.   Quit();
  1348. }
  1349.  
  1350. LONG ShowReq(char *text,char *gadgets,...)
  1351. {
  1352. va_list va;
  1353. LONG req_return;
  1354. struct EasyStruct req =
  1355.   { sizeof(struct EasyStruct),0,NAME,NULL,NULL };
  1356.  
  1357.   SleepWindows();
  1358.   req.es_TextFormat = text;
  1359.   req.es_GadgetFormat = gadgets;
  1360.   va_start(va,gadgets);
  1361.   req_return = EasyRequestArgs(FontWnd,&req,NULL,va);
  1362.   va_end(va);
  1363.   WakeWindows();
  1364.   return req_return;
  1365. }
  1366.  
  1367. void ClrDisposeObject(Object **obj)
  1368. {
  1369.   if (*obj)
  1370.   {
  1371.     DisposeObject(*obj);
  1372.     *obj = NULL;
  1373.   }
  1374. }
  1375.  
  1376. void ClrWindowClose(Object **obj,struct Window **wnd)
  1377. {
  1378.   if (*wnd)
  1379.   {
  1380.     WindowClose(*obj);
  1381.     *wnd = NULL;
  1382.   }
  1383. }
  1384.  
  1385. void SleepWindows(void)
  1386. {
  1387. struct CharNode *node;
  1388.  
  1389.   if (FontWnd)
  1390.   {
  1391.     WindowBusy(FontWndObj);
  1392.     if (ParamWnd) WindowBusy(ParamWndObj);
  1393.     if (PrefsWnd) WindowBusy(PrefsWndObj);
  1394.     if (AssignWnd) WindowBusy(AssignWndObj);
  1395.     if (ResetKernWnd) WindowBusy(ResetKernWndObj);
  1396.     if (EditCharWnd) WindowBusy(EditCharWndObj);
  1397.     if (WidthWnd) WindowBusy(WidthWndObj);
  1398.     if (KernWnd) WindowBusy(KernWndObj);
  1399.     if (PreviewWnd) WindowBusy(PreviewWndObj);
  1400.     node = (struct CharNode *)CharWndList->lh_Head;
  1401.     while (node->chln_Node.ln_Succ)
  1402.     {
  1403.       WindowBusy(node->chln_Object);
  1404.       node =(struct CharNode *) node->chln_Node.ln_Succ;
  1405.     }
  1406.   }
  1407. }
  1408.  
  1409. void WakeWindows(void)
  1410. {
  1411. struct CharNode *node;
  1412.  
  1413.   if (FontWnd)
  1414.   {
  1415.     WindowReady(FontWndObj);
  1416.     if (ParamWnd) WindowReady(ParamWndObj);
  1417.     if (PrefsWnd) WindowReady(PrefsWndObj);
  1418.     if (AssignWnd) WindowReady(AssignWndObj);
  1419.     if (ResetKernWnd) WindowReady(ResetKernWndObj);
  1420.     if (EditCharWnd) WindowReady(EditCharWndObj);
  1421.     if (WidthWnd) WindowReady(WidthWndObj);
  1422.     if (KernWnd) WindowReady(KernWndObj);
  1423.     if (PreviewWnd) WindowReady(PreviewWndObj);
  1424.     node = (struct CharNode *)CharWndList->lh_Head;
  1425.     while (node->chln_Node.ln_Succ)
  1426.     {
  1427.       WindowReady(node->chln_Object);
  1428.       node = (struct CharNode *)node->chln_Node.ln_Succ;
  1429.     }
  1430.   }
  1431. }
  1432.  
  1433. BOOL UnpackChar(struct Character *chr,struct TextFont *font,ULONG i)
  1434. {
  1435. struct charDef *def;
  1436. ULONG j,k,mod,off,width,modj,widthj;
  1437. UBYTE *data;
  1438.  
  1439.   mod = font->tf_Modulo;
  1440.   data = (UBYTE *)font->tf_CharData;
  1441.   def = ((struct charDef *)(font->tf_CharLoc))+i;
  1442.   off = def->charOffset;
  1443.   chr->chr_Width = def->charBitWidth;
  1444.   if ((width = chr->chr_Width) > 0)
  1445.   {
  1446.     if ((chr->chr_Data = AllocVec(chr->chr_Width*chr->chr_Height,MEMF_ANY))
  1447.       == NULL) return (FALSE);
  1448.     for (j = 0; j < chr->chr_Height; j++)
  1449.     {
  1450.       modj = mod*j;
  1451.       widthj = width*j;
  1452.       for (k = 0; k < width; k++)
  1453.         *(chr->chr_Data+widthj+k) = GETBIT(data+modj,off+k);
  1454.     }
  1455.   }
  1456.   return (TRUE);
  1457. }
  1458.  
  1459. void KernTables(ULONG to, ULONG from)
  1460. {
  1461.   if (NewFont->tf_CharSpace)
  1462.     SpaceTable[to] = *((WORD *)(NewFont->tf_CharSpace)+from);
  1463.   if (NewFont->tf_CharKern)
  1464.     KernTable[to] = *((WORD *)(NewFont->tf_CharKern)+from);
  1465.   if ((NewFont->tf_CharSpace) || (NewFont->tf_CharKern))
  1466.     UseTable = TRUE;
  1467.   else
  1468.     UseTable = FALSE;
  1469. }
  1470.  
  1471. void ClearCurrentFont(void)
  1472. {
  1473. struct Character *chr;
  1474.  
  1475.   for (chr = CharBuffer; chr < CharBuffer+257; chr++)
  1476.   {
  1477.     if (chr->chr_Data) FreeVec(chr->chr_Data);
  1478.     chr->chr_Data = NULL;
  1479.   }
  1480. }
  1481.  
  1482. void OpenEditFontWnd(void)
  1483. {
  1484. Object *accept, *cancel;
  1485.  
  1486.   if (ParamWnd)
  1487.   {
  1488.     WindowToFront(ParamWnd);
  1489.     ActivateWindow(ParamWnd);
  1490.   }
  1491.   else
  1492.   {
  1493.     if (ParamWndObj == NULL)
  1494.     {
  1495.       PropLabels[0] = GetString(msgFontFixed);
  1496.       PropLabels[1] = GetString(msgFontProp);
  1497.       AspectLabels[0] = GetString(msgAspectNormal);
  1498.       AspectLabels[1] = GetString(msgAspectThin);
  1499.       AspectLabels[2] = GetString(msgAspectWide);
  1500.       SetupMenus(Menus);
  1501.  
  1502.       ParamWndObj = WindowObject,
  1503.     WINDOW_Screen,Screen,
  1504.     WINDOW_SharedPort,WndMsgPort,
  1505.     WINDOW_MenuStrip,Menus,
  1506.     WINDOW_Title,GetString(msgFontParamsTitle),
  1507.     WINDOW_HelpFile,NAME".guide",
  1508.     WINDOW_HelpNode,"params",
  1509.     WINDOW_SmartRefresh,TRUE,
  1510.     WINDOW_SizeGadget,FALSE,
  1511.     WINDOW_CloseOnEsc,TRUE,
  1512.     WINDOW_MasterGroup,
  1513.       VGroupObject,
  1514.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(4)),
  1515.         GROUP_BackFill,SHINE_RASTER,
  1516.         StartMember,
  1517.           VGroupObject,
  1518.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(2)),
  1519.         ButtonFrame,
  1520.         FRM_Recessed,TRUE,
  1521.         StartMember,
  1522.           PropCycle = KeyCycle(GetString(gadgFontType),PropLabels,
  1523.             Proportional,ID_PROPORTIONAL),
  1524.         EndMember,
  1525.         StartMember,
  1526.           HGroupObject,
  1527.             Spacing(SizeX(8)),
  1528.             StartMember,
  1529.               VGroupObject,
  1530.             Spacing(SizeY(2)),
  1531.             StartMember,
  1532.               HeightInt = TabKeyInteger(
  1533.                 GetString(gadgFontHeight),Height,5,ID_HEIGHT),
  1534.             EndMember,
  1535.             StartMember,
  1536.               BaseInt = TabKeyInteger(
  1537.                 GetString(gadgFontBaseline),Baseline,5,
  1538.                 ID_BASELINE),
  1539.             EndMember,
  1540.               EndObject,
  1541.             EndMember,
  1542.             StartMember,
  1543.               VGroupObject,
  1544.             Spacing(SizeY(2)),
  1545.             StartMember,
  1546.               WidthInt = TabKeyInteger(GetString(gadgFontWidth),
  1547.                 Width,5,ID_WIDTH),
  1548.             EndMember,
  1549.             StartMember,
  1550.               SmearInt = TabKeyInteger(GetString(gadgBoldSmear),
  1551.                 Smear,5,ID_SMEAR),
  1552.             EndMember,
  1553.               EndObject,
  1554.             EndMember,
  1555.           EndObject,
  1556.         EndMember,
  1557.           EndObject,
  1558.         EndMember,
  1559.         StartMember,
  1560.           VGroupObject,
  1561.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(2)),
  1562.         ButtonFrame,
  1563.         FRM_Recessed,TRUE,
  1564.         StartMember,
  1565.           HGroupObject,
  1566.             Spacing(SizeX(8)),
  1567.             StartMember,
  1568.               VGroupObject,
  1569.             Spacing(SizeY(2)),
  1570.             StartMember,
  1571.               NormalCheck =
  1572.                 KeyCheckBox(GetString(gadgFontNormal),Normal,
  1573.                   ID_NORMAL),
  1574.             EndMember,
  1575.             StartMember,
  1576.               ItalicCheck =
  1577.                 KeyCheckBox(GetString(gadgFontItalic),Italic,
  1578.                   ID_ITALIC),
  1579.             EndMember,
  1580.               EndObject,
  1581.             EndMember,
  1582.             StartMember,
  1583.               VGroupObject,
  1584.             Spacing(SizeY(2)),
  1585.             StartMember,
  1586.               BoldCheck = KeyCheckBox(GetString(gadgFontBold),
  1587.                 Bold,ID_BOLD),
  1588.             EndMember,
  1589.             StartMember,
  1590.               UnderCheck =
  1591.                 KeyCheckBox(GetString(gadgFontUnderline),ULine,
  1592.                   ID_ULINE),
  1593.             EndMember,
  1594.               EndObject,
  1595.             EndMember,
  1596.             StartMember,
  1597.               VGroupObject,
  1598.             Spacing(SizeY(2)),
  1599.             StartMember,
  1600.               ExtCheck =
  1601.                 KeyCheckBox(GetString(gadgFontExtended),Extended,
  1602.                   ID_EXTEND),
  1603.             EndMember,
  1604.             StartMember,
  1605.               RevCheck =
  1606.                 KeyCheckBox(GetString(gadgFontReversed),Reversed,
  1607.                   ID_REVERSE),
  1608.             EndMember,
  1609.               EndObject,
  1610.             EndMember,
  1611.           EndObject,
  1612.         EndMember,
  1613.         StartMember,
  1614.           HGroupObject,
  1615.             Spacing(SizeX(8)),
  1616.             StartMember,
  1617.               AspectCycle = KeyPopCycle(GetString(gadgFontAspect),
  1618.             AspectLabels,Aspect,ID_ASPECT),
  1619.             EndMember,
  1620.             StartMember,
  1621.               BlankButton = KeyButton(GetString(gadgFontBlank),
  1622.             ID_BLANK),
  1623.               Weight(20),
  1624.             EndMember,
  1625.           EndObject,
  1626.         EndMember,
  1627.           EndObject,
  1628.         EndMember,
  1629.         StartMember,
  1630.           HGroupObject,
  1631.         Spacing(SizeX(8)),
  1632.         EqualWidth,
  1633.         StartMember,
  1634.           accept = KeyButton(GetString(gadgAccept),ID_ACCEPT),
  1635.         EndMember,
  1636.             StartMember,
  1637.           cancel = KeyButton(GetString(gadgCancel),ID_CANCEL),
  1638.         EndMember,
  1639.           EndObject,
  1640.           FixMinHeight,
  1641.         EndMember,
  1642.       EndObject,
  1643.     EndObject;
  1644.       if (ParamWndObj == NULL) ErrorCode(NEWWINDOW);
  1645.       SetLabelKey(ParamWndObj,accept,gadgAccept);
  1646.       SetLabelKey(ParamWndObj,cancel,gadgCancel);
  1647.       SetLabelKey(ParamWndObj,PropCycle,gadgFontType);
  1648.       SetLabelKey(ParamWndObj,HeightInt,gadgFontHeight);
  1649.       SetLabelKey(ParamWndObj,WidthInt,gadgFontWidth);
  1650.       SetLabelKey(ParamWndObj,BaseInt,gadgFontBaseline);
  1651.       SetLabelKey(ParamWndObj,SmearInt,gadgBoldSmear);
  1652.       SetLabelKey(ParamWndObj,NormalCheck,gadgFontNormal);
  1653.       SetLabelKey(ParamWndObj,BoldCheck,gadgFontBold);
  1654.       SetLabelKey(ParamWndObj,ItalicCheck,gadgFontItalic);
  1655.       SetLabelKey(ParamWndObj,UnderCheck,gadgFontUnderline);
  1656.       SetLabelKey(ParamWndObj,ExtCheck,gadgFontExtended);
  1657.       SetLabelKey(ParamWndObj,RevCheck,gadgFontReversed);
  1658.       SetLabelKey(ParamWndObj,AspectCycle,gadgFontAspect);
  1659.       SetLabelKey(ParamWndObj,BlankButton,gadgFontBlank);
  1660.       DoMethod(ParamWndObj,WM_TABCYCLE_ORDER,
  1661.     HeightInt,WidthInt,BaseInt,SmearInt,NULL);
  1662.     }
  1663.  
  1664.     SetAttrs(PropCycle,CYC_Active,Proportional,TAG_DONE);
  1665.     SetAttrs(HeightInt,STRINGA_LongVal,Height,TAG_DONE);
  1666.     SetAttrs(BaseInt,STRINGA_LongVal,Baseline,TAG_DONE);
  1667.     SetAttrs(WidthInt,STRINGA_LongVal,Width,TAG_DONE);
  1668.     SetAttrs(SmearInt,STRINGA_LongVal,Smear,TAG_DONE);
  1669.     SetAttrs(NormalCheck,GA_Selected,Normal,TAG_DONE);
  1670.     SetAttrs(ItalicCheck,GA_Selected,Italic,TAG_DONE);
  1671.     SetAttrs(BoldCheck,GA_Selected,Bold,TAG_DONE);
  1672.     SetAttrs(UnderCheck,GA_Selected,ULine,TAG_DONE);
  1673.     SetAttrs(ExtCheck,GA_Selected,Extended,TAG_DONE);
  1674.     SetAttrs(RevCheck,GA_Selected,Reversed,TAG_DONE);
  1675.     SetAttrs(AspectCycle,CYC_Active,Aspect,TAG_DONE);
  1676.     if ((ParamWnd = WindowOpen(ParamWndObj)) == NULL) ErrorCode(OPENWINDOW);
  1677.   }
  1678. }
  1679.  
  1680. void CloseEditFontWnd(BOOL obj)
  1681. {
  1682.   ClrWindowClose(&ParamWndObj,&ParamWnd);
  1683.   if (obj) ClrDisposeObject(&ParamWndObj);
  1684. }
  1685.  
  1686. __geta4 LONG TBCompareFunc(__a0 struct Hook *hook, __a2 Object *o,
  1687.   __a1 struct lvCompare *lvc)
  1688. {
  1689.   if (lvc->lvc_EntryA < lvc->lvc_EntryB) return -1;
  1690.   if (lvc->lvc_EntryA > lvc->lvc_EntryB) return 1;
  1691.   return 0;
  1692. }
  1693.  
  1694. __geta4 LONG TBResourceFunc(__a0 struct Hook *hook, __a2 Object *o,
  1695.   __a1 struct lvResource *lvr)
  1696. {
  1697.   if (lvr->lvr_Command == LVRC_MAKE) return lvr->lvr_Entry;
  1698.   return 0;
  1699. }
  1700.  
  1701. __geta4 char *TBDisplayFunc(__a0 struct Hook *hook, __a2 Object *o,
  1702.   __a1 struct lvRender *lvr)
  1703. {
  1704.   switch (lvr->lvr_Entry)
  1705.   {
  1706.     case FTBAR_WIDTHL:
  1707.       return GetString(prefsDecWidth);
  1708.     case FTBAR_WIDTHR:
  1709.       return GetString(prefsIncWidth);
  1710.     case FTBAR_MOVEL:
  1711.       return GetString(prefsMoveLeft);
  1712.     case FTBAR_MOVER:
  1713.       return GetString(prefsMoveRight);
  1714.     case FTBAR_MOVEU:
  1715.       return GetString(prefsMoveUp);
  1716.     case FTBAR_MOVED:
  1717.       return GetString(prefsMoveDown);
  1718.     case FTBAR_KERN:
  1719.       return GetString(prefsKerning);
  1720.     case FTBAR_WIDTH:
  1721.       return GetString(prefsWidthWin);
  1722.     case FTBAR_ZOOMIN:
  1723.       return GetString(prefsZoomIn);
  1724.     case FTBAR_ZOOMOUT:
  1725.       return GetString(prefsZoomOut);
  1726.     case FTBAR_FLIPH:
  1727.       return GetString(prefsFlipHoriz);
  1728.     case FTBAR_FLIPV:
  1729.       return GetString(prefsFlipVert);
  1730.     default:
  1731.       return "";
  1732.   }
  1733. }
  1734.  
  1735. void OpenPrefsWnd(void)
  1736. {
  1737. Object *save, *use, *cancel, *select, *page;
  1738. static STRPTR width_labels[] = { "4","8","16","32",NULL };
  1739. static ULONG map[] = { CYC_Active,PAGE_Active,TAG_DONE };
  1740.  
  1741. extern struct VectorItem LineArrowLeft[], LineArrowRight[];
  1742. extern struct VectorItem SolidArrowLeft[], SolidArrowRight[];
  1743. extern struct VectorItem SolidArrowUp[], SolidArrowDown[];
  1744. extern struct VectorItem KernImage[], WidthImage[];
  1745. extern struct VectorItem ZoomInImage[], ZoomOutImage[];
  1746.  
  1747.   if (PrefsWnd)
  1748.   {
  1749.     WindowToFront(PrefsWnd);
  1750.     ActivateWindow(PrefsWnd);
  1751.   }
  1752.   else
  1753.   {
  1754.     if (PrefsWndObj == NULL)
  1755.     {
  1756.       PrefsPages[0] = GetString(msgPrefsScreen);
  1757.       PrefsPages[1] = GetString(msgPrefsToolBar);
  1758.       PrefsPages[2] = GetString(msgPrefsEdit);
  1759.       PrefsPages[3] = GetString(msgPrefsSelect);
  1760.       PrefsPages[4] = GetString(msgPrefsMisc);
  1761.       BorderLabels[0] = GetString(msgBorderNo);
  1762.       BorderLabels[1] = GetString(msgBorderYes);
  1763.       BorderLabels[2] = GetString(msgBorderGrid);
  1764.       SaveLabels[0] = GetString(msgPrefsEnv);
  1765.       SaveLabels[1] = GetString(msgPrefsProg);
  1766.       SetupMenus(Menus);
  1767.       if ((TBDisplayHook = AllocVec(sizeof(struct Hook),MEMF_CLEAR)) == NULL) ErrorCode(ALLOCVEC);
  1768.       TBDisplayHook->h_Entry = (HOOKFUNC)TBDisplayFunc;
  1769.       if ((TBResourceHook = AllocVec(sizeof(struct Hook),MEMF_CLEAR)) == NULL) ErrorCode(ALLOCVEC);
  1770.       TBResourceHook->h_Entry = (HOOKFUNC)TBResourceFunc;
  1771.       if ((TBCompareHook = AllocVec(sizeof(struct Hook),MEMF_CLEAR)) == NULL) ErrorCode(ALLOCVEC);
  1772.       TBCompareHook->h_Entry = (HOOKFUNC)TBCompareFunc;
  1773.  
  1774.       PrefsWndObj = WindowObject,
  1775.     WINDOW_Screen,Screen,
  1776.     WINDOW_SharedPort,WndMsgPort,
  1777.     WINDOW_MenuStrip,Menus,
  1778.     WINDOW_Title,GetString(msgPrefsTitle),
  1779.     WINDOW_HelpFile,NAME".guide",
  1780.     WINDOW_HelpNode,"prefs",
  1781.         WINDOW_ScaleHeight,1,
  1782.     WINDOW_ToolTicks,10,
  1783.     WINDOW_SmartRefresh,TRUE,
  1784.     WINDOW_SizeGadget,FALSE,
  1785.     WINDOW_CloseOnEsc,TRUE,
  1786.     WINDOW_MasterGroup,
  1787.       VGroupObject,
  1788.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(4)),
  1789.         GROUP_BackFill,SHINE_RASTER,
  1790.             StartMember,
  1791.           select = CycleObject,
  1792.         ButtonFrame,
  1793.         CYC_Labels,PrefsPages,
  1794.         CYC_Popup,TRUE,
  1795.           EndObject,
  1796.           FixMinHeight,
  1797.         EndMember,
  1798.         StartMember,
  1799.           page = PageObject,
  1800.  
  1801.         PageMember,
  1802.           VGroupObject,
  1803.             HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(2)),
  1804.             ButtonFrame,
  1805.             FRM_Recessed,TRUE,
  1806.             VarSpace(50),
  1807.             StartMember,
  1808.               HGroupObject,
  1809.             VarSpace(50),
  1810.             StartMember,
  1811.               CustButton = KeyCheckBox(GetString(gadgCustomScr),
  1812.                 CustomScreen,ID_CUSTOM),
  1813.             EndMember,
  1814.             VarSpace(50),
  1815.               EndObject,
  1816.             EndMember,
  1817.             StartMember,
  1818.               HGroupObject,
  1819.             VarSpace(0),
  1820.             FixMinHeight,
  1821.             EqualHeight,
  1822.             StartMember,
  1823.               ModeInfo = InfoObject,
  1824.                 UScoreLabel(GetString(gadgMode),'_'),
  1825.                 ButtonFrame,
  1826.                 FRM_Flags,FRF_RECESSED,
  1827.                 INFO_MinLines,1,
  1828.                 INFO_HorizOffset,6,
  1829.                 INFO_VertOffset,4,
  1830.               EndObject,
  1831.               FixMinHeight,
  1832.             EndMember,
  1833.             StartMember,
  1834.               ModeButton = ButtonObject,
  1835.                 PopUp,
  1836.                 ButtonFrame,
  1837.                 GA_ID,ID_CHOOSEMODE,
  1838.               EndObject,
  1839.               FixMinWidth,
  1840.             EndMember,
  1841.               EndObject,
  1842.               FixMinHeight,
  1843.             EndMember,
  1844.             StartMember,
  1845.               HGroupObject,
  1846.             VarSpace(0),
  1847.             FixMinHeight,
  1848.             EqualHeight,
  1849.             StartMember,
  1850.               FontInfo = InfoObject,
  1851.                 UScoreLabel(GetString(gadgScreenFont),'_'),
  1852.                 ButtonFrame,
  1853.                 FRM_Flags,FRF_RECESSED,
  1854.                 INFO_MinLines,1,
  1855.                 INFO_HorizOffset,6,
  1856.                 INFO_VertOffset,4,
  1857.               EndObject,
  1858.               FixMinHeight,
  1859.             EndMember,
  1860.             StartMember,
  1861.               FontButton = ButtonObject,
  1862.                 PopUp,
  1863.                 ButtonFrame,
  1864.                 GA_ID,ID_CHOOSEFONT,
  1865.               EndObject,
  1866.               FixMinWidth,
  1867.             EndMember,
  1868.               EndObject,
  1869.               FixMinHeight,
  1870.             EndMember,
  1871.             StartMember,
  1872.               PubStr = StringObject,
  1873.             UScoreLabel(GetString(gadgPubScreen),'_'),
  1874.             RidgeFrame,
  1875.             STRINGA_MaxChars,MAXPUBSCREENNAME,
  1876.             GA_ID,ID_PUBNAME,
  1877.               EndObject,
  1878.               NoAlign,
  1879.               FixMinHeight,
  1880.             EndMember,
  1881.             VarSpace(50),
  1882.           EndObject,
  1883.  
  1884.         PageMember,
  1885.           VGroupObject,
  1886.             HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(2)),
  1887.             ButtonFrame,
  1888.             FRM_Recessed,TRUE,
  1889.             StartMember,
  1890.               HGroupObject,
  1891.             StartMember,
  1892.               HGroupObject,
  1893.                 Spacing(SizeX(4)),
  1894.                 StartMember,
  1895.                   ToolBarOut = NewObject(LVClass,NULL,
  1896.                 FL_SortDrops,1,
  1897.                 BT_DragObject,1,
  1898.                 BT_DropObject,1,
  1899.                 LISTV_MultiSelect,1,
  1900.                 LISTV_DisplayHook,TBDisplayHook,
  1901.                 LISTV_ResourceHook,TBResourceHook,
  1902.                 LISTV_CompareHook,TBCompareHook,
  1903.                 BT_ToolTip,GetString(gadgToolBarOut),
  1904.                 TAG_DONE),
  1905.                 EndMember,
  1906.                 StartMember,
  1907.                   ToolBarIn = NewObject(LVClass,NULL,
  1908.                 FL_SortDrops,1,
  1909.                 BT_DragObject,1,
  1910.                 BT_DropObject,1,
  1911.                 LISTV_MultiSelect,1,
  1912.                 LISTV_DisplayHook,TBDisplayHook,
  1913.                 LISTV_ResourceHook,TBResourceHook,
  1914.                 LISTV_CompareHook,TBCompareHook,
  1915.                 BT_ToolTip,GetString(gadgToolBarIn),
  1916.                 TAG_DONE),
  1917.                 EndMember,
  1918.               EndObject,
  1919.             EndMember,
  1920.               EndObject,
  1921.             EndMember,
  1922.             StartMember,
  1923.               HGroupObject,
  1924.             Spacing(SizeX(8)),
  1925.             VarSpace(100),
  1926.             StartMember,
  1927.               VecInt = StringObject,
  1928.                 RidgeFrame,
  1929.                 UScoreLabel(GetString(gadgToolBarHeight),'_'),
  1930.                 STRINGA_LongVal,0,
  1931.                 STRINGA_MaxChars,5,
  1932.                 STRINGA_MinCharsVisible,5,
  1933.                 GA_ID,ID_VECHEIGHT,
  1934.               EndObject,
  1935.             EndMember,
  1936.             StartMember,
  1937.               VGroupObject,
  1938.                 VarSpace(60),
  1939.                 StartMember,
  1940.                   AutoCheck = KeyCheckBox(GetString(gadgAuto),
  1941.                 FALSE,ID_AUTOHEIGHT),
  1942.                 EndMember,
  1943.                 VarSpace(50),
  1944.               EndObject,
  1945.             EndMember,
  1946.             VarSpace(100),
  1947.               EndObject,
  1948.               FixMinHeight,
  1949.             EndMember,
  1950.           EndObject,
  1951.  
  1952.         PageMember,
  1953.           VGroupObject,
  1954.             HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(2)),
  1955.             ButtonFrame,
  1956.             FRM_Recessed,TRUE,
  1957.             StartMember,
  1958.               VGroupObject,
  1959.             HOffset(SizeX(8)),VOffset(SizeY(4)),
  1960.             Spacing(SizeY(2)),
  1961.             NeXTFrame, 
  1962.             FrameTitle(GetString(msgPixels)),
  1963.             StartMember,
  1964.               HGroupObject,
  1965.                 Spacing(SizeX(8)),
  1966.                 EqualWidth,
  1967.                 StartMember,
  1968.                   PixelXInt = TabKeyInteger(
  1969.                 GetString(gadgPixelWidth),Prefs.PixelX,3,
  1970.                 ID_PIXELWIDTH),
  1971.                   FixMinHeight,
  1972.                 EndMember,
  1973.                 StartMember,
  1974.                   PixelYInt = TabKeyInteger(
  1975.                 GetString(gadgPixelHeight),Prefs.PixelY,3,
  1976.                 ID_PIXELHEIGHT),
  1977.                   FixMinHeight,
  1978.                 EndMember,
  1979.               EndObject,
  1980.               NoAlign,
  1981.             EndMember,
  1982.             StartMember,
  1983.               HGroupObject,
  1984.                 Spacing(SizeX(8)),
  1985.                 StartMember,
  1986.                   PixelCycle = CycleObject,
  1987.                 UScoreLabel(GetString(gadgPixelBorder),'_'),
  1988.                 ButtonFrame,
  1989.                 CYC_Labels,BorderLabels,
  1990.                 CYC_Popup,TRUE,
  1991.                 GA_ID,ID_PIXELBORDER,
  1992.                   EndObject,
  1993.                 EndMember,
  1994.                 StartMember,
  1995.                   VGroupObject,
  1996.                 VarSpace(60),
  1997.                 StartMember,
  1998.                   BLineCheck = KeyCheckBox(GetString(gadgShowBLine),FALSE,ID_SHOWBASELINE),
  1999.                 EndMember,
  2000.                 VarSpace(50),
  2001.                   EndObject,
  2002.                 EndMember,
  2003.               EndObject,
  2004.               NoAlign,
  2005.             EndMember,
  2006.               EndObject,
  2007.             EndMember,
  2008.             StartMember,
  2009.               HGroupObject,
  2010.             Spacing(SizeX(8)),
  2011.             VarSpace(50),
  2012.             StartMember,
  2013.               MaxCheck = KeyCheckBox(GetString(gadgMaxWindow),FALSE,ID_MAXWIN),
  2014.             EndMember,
  2015.             StartMember,
  2016.               ToggleCheck = KeyCheckBox(GetString(gadgToggle),TRUE,ID_TOGGLE),
  2017.             EndMember,
  2018.             VarSpace(50),
  2019.               EndObject,
  2020.             EndMember,
  2021.           EndObject,
  2022.  
  2023.         PageMember,
  2024.           VGroupObject,
  2025.             HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(2)),
  2026.             ButtonFrame,
  2027.             FRM_Recessed,TRUE,
  2028.             VarSpace(50),
  2029.             StartMember,
  2030.               HGroupObject,
  2031.             Spacing(SizeX(8)),
  2032.             VarSpace(50),
  2033.             StartMember,
  2034.               SizeCheck = KeyCheckBox(GetString(gadgSizeWin),
  2035.                 FALSE,ID_CHARSIZE),
  2036.             EndMember,
  2037.             StartMember,
  2038.               ShiftCheck = KeyCheckBox(GetString(gadgShift),
  2039.                 FALSE,ID_INVERTSHIFT),
  2040.             EndMember,
  2041.             VarSpace(50),
  2042.               EndObject,
  2043.             EndMember,
  2044.             StartMember,
  2045.               HGroupObject,
  2046.             Spacing(SizeX(8)),
  2047.             StartMember,
  2048.               ChrWCycle = CycleObject,
  2049.                 UScoreLabel(GetString(gadgWidthCycle),'_'),
  2050.                 ButtonFrame,
  2051.                 CYC_Labels,width_labels,
  2052.                 CYC_Popup,TRUE,
  2053.                 GA_ID,ID_CHARWIDE,
  2054.               EndObject,
  2055.             EndMember,
  2056.             StartMember,
  2057.               ChrHInt = KeyInteger(GetString(gadgSelWinHeight),
  2058.                 0,3,ID_CHARHIGH),
  2059.             EndMember,
  2060.               EndObject,
  2061.             EndMember,
  2062.             StartMember,
  2063.               HGroupObject,
  2064.             FixMinHeight,
  2065.             EqualHeight,
  2066.             StartMember,
  2067.               ChrFontInfo = InfoObject,
  2068.                 UScoreLabel(GetString(gadgSelWinFont),'_'),
  2069.                 ButtonFrame,
  2070.                 FRM_Flags,FRF_RECESSED,
  2071.                 INFO_MinLines,1,
  2072.                 INFO_HorizOffset,6,
  2073.                 INFO_VertOffset,4,
  2074.               EndObject,
  2075.               FixMinHeight,
  2076.             EndMember,
  2077.             StartMember,
  2078.               ChrFontButton = ButtonObject,
  2079.                 PopUp,
  2080.                 ButtonFrame,
  2081.                 GA_ID,ID_CHOOSEFIXFONT,
  2082.               EndObject,
  2083.               FixMinWidth,
  2084.             EndMember,
  2085.               EndObject,
  2086.               FixMinHeight,
  2087.             EndMember,
  2088.             VarSpace(50),
  2089.           EndObject,
  2090.  
  2091.         PageMember,
  2092.           VGroupObject,
  2093.             HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(2)),
  2094.             ButtonFrame,
  2095.             FRM_Recessed,TRUE,
  2096.             VarSpace(50),
  2097.             StartMember,
  2098.               HGroupObject,
  2099.             HOffset(SizeX(8)),VOffset(SizeY(4)),
  2100.             Spacing(SizeX(4)),
  2101.             NeXTFrame, 
  2102.             FrameTitle(GetString(msgSavePrefsTo)),
  2103.             Place(PLACE_ABOVE),
  2104.             StartMember,
  2105.               SaveCycle = CycleObject,
  2106.                 ButtonFrame,
  2107.                 CYC_Labels,SaveLabels,
  2108.                 CYC_Active,Prefs.SaveTo,
  2109.                 CYC_Popup,TRUE,
  2110.                 GA_ID,ID_SAVETO,
  2111.               EndObject,
  2112.             EndMember,
  2113.               EndObject,
  2114.             EndMember,
  2115.             StartMember,
  2116.               HGroupObject,
  2117.             VarSpace(50),
  2118.             StartMember,
  2119.               VGroupObject,
  2120.                 Spacing(SizeY(2)),
  2121.                 StartMember,
  2122.                   QuitCheck = KeyCheckBox(GetString(gadgQuit),FALSE,ID_CONFIRMQUIT),
  2123.                 EndMember,
  2124.                 StartMember,
  2125.                   QueryCheck = KeyCheckBox(GetString(gadgQueryWidth),FALSE,ID_QUERYWIDTH),
  2126.                 EndMember,
  2127.               EndObject,
  2128.             EndMember,
  2129.             VarSpace(50),
  2130.               EndObject,
  2131.             EndMember,
  2132.             VarSpace(50),
  2133.           EndObject,
  2134.  
  2135.           EndObject,
  2136.         EndMember,
  2137.         StartMember,
  2138.           HGroupObject,
  2139.         Spacing(SizeX(8)),
  2140.         EqualWidth,
  2141.         StartMember,
  2142.           save = KeyButton(GetString(gadgPrefsSave),ID_ACCEPT),
  2143.         EndMember,
  2144.         StartMember,
  2145.           use = KeyButton(GetString(gadgPrefsUse),ID_USE),
  2146.         EndMember,
  2147.             StartMember,
  2148.           cancel = KeyButton(GetString(gadgCancel),ID_CANCEL),
  2149.         EndMember,
  2150.           EndObject,
  2151.           FixMinHeight,
  2152.         EndMember,
  2153.       EndObject,
  2154.     EndObject;
  2155.       if (PrefsWndObj == NULL) ErrorCode(NEWWINDOW);
  2156.  
  2157.       SetLabelKey(PrefsWndObj,save,gadgPrefsSave);
  2158.       SetLabelKey(PrefsWndObj,use,gadgPrefsUse);
  2159.       SetLabelKey(PrefsWndObj,cancel,gadgCancel);
  2160.  
  2161.       SetLabelKey(PrefsWndObj,CustButton,gadgCustomScr);
  2162.       SetLabelKey(PrefsWndObj,ModeButton,gadgMode);
  2163.       SetLabelKey(PrefsWndObj,FontButton,gadgScreenFont);
  2164.       SetLabelKey(PrefsWndObj,PubStr,gadgPubScreen);
  2165.  
  2166.       SetLabelKey(PrefsWndObj,VecInt,gadgToolBarHeight);
  2167.       SetLabelKey(PrefsWndObj,AutoCheck,gadgAuto);
  2168.  
  2169.       SetLabelKey(PrefsWndObj,PixelXInt,gadgPixelWidth);
  2170.       SetLabelKey(PrefsWndObj,PixelYInt,gadgPixelHeight);
  2171.       SetLabelKey(PrefsWndObj,PixelCycle,gadgPixelBorder);
  2172.       SetLabelKey(PrefsWndObj,MaxCheck,gadgMaxWindow);
  2173.       SetLabelKey(PrefsWndObj,BLineCheck,gadgShowBLine);
  2174.       SetLabelKey(PrefsWndObj,ToggleCheck,gadgToggle);
  2175.  
  2176.       SetLabelKey(PrefsWndObj,SizeCheck,gadgSizeWin);
  2177.       SetLabelKey(PrefsWndObj,ShiftCheck,gadgShift);
  2178.       SetLabelKey(PrefsWndObj,ChrWCycle,gadgWidthCycle);
  2179.       SetLabelKey(PrefsWndObj,ChrHInt,gadgSelWinHeight);
  2180.       SetLabelKey(PrefsWndObj,ChrFontButton,gadgSelWinFont);
  2181.  
  2182.       GadgetKey(PrefsWndObj,SaveCycle,"v");
  2183.       SetLabelKey(PrefsWndObj,QuitCheck,gadgQuit);
  2184.       SetLabelKey(PrefsWndObj,QueryCheck,gadgQueryWidth);
  2185.       GadgetKey(PrefsWndObj,select,"\\");
  2186.  
  2187.       DoMethod(PrefsWndObj,WM_TABCYCLE_ORDER,PixelXInt,PixelYInt,NULL);
  2188.       AddMap(select,page,map);
  2189.     }
  2190.  
  2191.     SetAttrs(CustButton,GA_Selected,CustomScreen,TAG_DONE);
  2192.     SetAttrs(ModeButton,
  2193.       GA_Disabled,(CustomScreen != FALSE) ? FALSE : TRUE,TAG_DONE);
  2194.     SetAttrs(FontButton,
  2195.       GA_Disabled,(CustomScreen != FALSE) ? FALSE : TRUE,TAG_DONE);
  2196.     PrefScrModeID = Prefs.ScrModeID;
  2197.     PrefScrDepth = Prefs.ScrDepth;
  2198.     GetDisplayInfoData(NULL,(UBYTE *)&ModeIDName,sizeof(struct NameInfo),
  2199.       DTAG_NAME,PrefScrModeID);
  2200.     SetAttrs(ModeInfo,INFO_TextFormat,ModeIDName.Name,TAG_DONE);
  2201.     strcpy(PrefScrFontName,Prefs.ScrFontName);
  2202.     PrefScrFontHeight = Prefs.ScrFontHeight;
  2203.     WriteFont(PrefScrBuffer,Prefs.ScrFontName,Prefs.ScrFontHeight);
  2204.     SetAttrs(FontInfo,INFO_TextFormat,PrefScrBuffer,TAG_DONE);
  2205.     strcpy(PrefThisPubName,Prefs.ThisPubName);
  2206.     strcpy(PrefDefPubName,Prefs.DefPubName);
  2207.     SetAttrs(PubStr,STRINGA_TextVal,GetPubName(CustomScreen),TAG_DONE);
  2208.  
  2209.     ClearList(NULL,ToolBarOut);
  2210.     ClearList(NULL,ToolBarIn);
  2211.     AddToolBarList(FTBAR_WIDTHL);
  2212.     AddToolBarList(FTBAR_WIDTHR);
  2213.     AddToolBarList(FTBAR_MOVEL);
  2214.     AddToolBarList(FTBAR_MOVER);
  2215.     AddToolBarList(FTBAR_MOVEU);
  2216.     AddToolBarList(FTBAR_MOVED);
  2217.     AddToolBarList(FTBAR_KERN);
  2218.     AddToolBarList(FTBAR_WIDTH);
  2219.     AddToolBarList(FTBAR_ZOOMIN);
  2220.     AddToolBarList(FTBAR_ZOOMOUT);
  2221.     AddToolBarList(FTBAR_FLIPH);
  2222.     AddToolBarList(FTBAR_FLIPV);
  2223.     SetAttrs(ToolBarIn,FL_AcceptDrop,ToolBarOut,TAG_DONE);
  2224.     SetAttrs(ToolBarOut,FL_AcceptDrop,ToolBarIn,TAG_DONE);
  2225.     SetAttrs(AutoCheck,GA_Selected,AutoHeight,TAG_DONE);
  2226.     SetAttrs(VecInt,
  2227.       STRINGA_LongVal,Prefs.VecHeight,
  2228.       GA_Disabled,AutoHeight,TAG_DONE);
  2229.  
  2230.     SetAttrs(PixelXInt,STRINGA_LongVal,Prefs.PixelX,TAG_DONE);
  2231.     SetAttrs(PixelYInt,STRINGA_LongVal,Prefs.PixelY,TAG_DONE);
  2232.     SetAttrs(PixelCycle,CYC_Active,PixelBorder,TAG_DONE);
  2233.     SetAttrs(MaxCheck,GA_Selected,MaxWindow,TAG_DONE);
  2234.     SetAttrs(BLineCheck,GA_Selected,ShowBLine,TAG_DONE);
  2235.     SetAttrs(ToggleCheck,GA_Selected,Toggle,TAG_DONE);
  2236.  
  2237.     SetAttrs(SizeCheck,GA_Selected,Prefs.CharSize,TAG_DONE);
  2238.     SetAttrs(ShiftCheck,GA_Selected,InvertShift,TAG_DONE);
  2239.     SetAttrs(ChrWCycle,CYC_Active,(ULONG)Prefs.CharWidth,TAG_DONE);
  2240.     SetAttrs(ChrHInt,STRINGA_LongVal,Prefs.CharHeight,TAG_DONE);
  2241.     strcpy(PrefFixFontName,Prefs.FixedFontName);
  2242.     PrefFixFontHeight = Prefs.FixedFontHeight;
  2243.     WriteFont(PrefFixBuffer,Prefs.FixedFontName,Prefs.FixedFontHeight);
  2244.     SetAttrs(ChrFontInfo,INFO_TextFormat,PrefFixBuffer,TAG_DONE);
  2245.  
  2246.     SetAttrs(SaveCycle,CYC_Active,Prefs.SaveTo,TAG_DONE);
  2247.     SetAttrs(QuitCheck,GA_Selected,ConfirmQuit,TAG_DONE);
  2248.     SetAttrs(QueryCheck,GA_Selected,QueryWidth,TAG_DONE);
  2249.     if ((PrefsWnd = WindowOpen(PrefsWndObj)) == NULL) ErrorCode(OPENWINDOW);
  2250.   }
  2251. }
  2252.  
  2253. void ClosePrefsWnd(BOOL obj)
  2254. {
  2255.   ClrWindowClose(&PrefsWndObj,&PrefsWnd);
  2256.   if (obj)
  2257.   {
  2258.     ClrDisposeObject(&PrefsWndObj);
  2259.     FreeVec(TBDisplayHook);
  2260.     TBDisplayHook = 0;
  2261.     FreeVec(TBResourceHook);
  2262.     TBResourceHook = 0;
  2263.     FreeVec(TBCompareHook);
  2264.     TBCompareHook = 0;
  2265.   }
  2266. }
  2267.  
  2268. void OpenAssignWnd(void)
  2269. {
  2270. Object *assign, *assignadd, *cancel;
  2271.  
  2272.   if (AssignWnd)
  2273.   {
  2274.     WindowToFront(AssignWnd);
  2275.     ActivateWindow(AssignWnd);
  2276.   }
  2277.   else
  2278.   {
  2279.     if (AssignWndObj == NULL)
  2280.     {
  2281.       SetupMenus(Menus);
  2282.       AssignWndObj = WindowObject,
  2283.     WINDOW_Screen,Screen,
  2284.     WINDOW_SharedPort,WndMsgPort,
  2285.     WINDOW_MenuStrip,Menus,
  2286.     WINDOW_Title,GetString(msgFontDirTitle),
  2287.     WINDOW_HelpFile,NAME".guide",
  2288.     WINDOW_HelpNode,"dir",
  2289.     WINDOW_ScaleWidth,26,
  2290.     WINDOW_SmartRefresh,TRUE,
  2291.     WINDOW_SizeGadget,FALSE,
  2292.     WINDOW_CloseOnEsc,TRUE,
  2293.     WINDOW_MasterGroup,
  2294.       VGroupObject,
  2295.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(4)),
  2296.         GROUP_BackFill,SHINE_RASTER,
  2297.         StartMember,
  2298.           HGroupObject,
  2299.         HOffset(SizeX(8)),VOffset(SizeY(4)),
  2300.         EqualHeight,
  2301.         ButtonFrame,
  2302.         FRM_Recessed,TRUE,
  2303.         StartMember,
  2304.           FontDirStr = StringObject,
  2305.             RidgeFrame,
  2306.             STRINGA_TextVal,FontPath,
  2307.             STRINGA_MaxChars,255,
  2308.             GA_ID,ID_ASSIGNSTR,
  2309.           EndObject,
  2310.         EndMember,
  2311.         StartMember,
  2312.           ButtonObject,
  2313.             GetPath,
  2314.             ButtonFrame,
  2315.             GA_ID,ID_ASSIGNPATH,
  2316.           EndObject,
  2317.           FixMinWidth,
  2318.         EndMember,
  2319.           EndObject,
  2320.         EndMember,
  2321.         StartMember,
  2322.           HGroupObject,
  2323.         Spacing(SizeX(8)),
  2324.         StartMember,
  2325.           assign = KeyButton(GetString(gadgAssign),ID_ASSIGN),
  2326.         EndMember,
  2327.             StartMember,
  2328.           assignadd = KeyButton(GetString(gadgAssignAdd),
  2329.             ID_ASSIGNADD),
  2330.         EndMember,
  2331.             StartMember,
  2332.           cancel = KeyButton(GetString(gadgCancel),ID_CANCEL),
  2333.         EndMember,
  2334.           EndObject,
  2335.           FixMinHeight,
  2336.         EndMember,
  2337.       EndObject,
  2338.     EndObject;
  2339.       if (AssignWndObj == NULL) ErrorCode(NEWWINDOW);
  2340.       SetLabelKey(AssignWndObj,assign,gadgAssign);
  2341.       SetLabelKey(AssignWndObj,assignadd,gadgAssignAdd);
  2342.       SetLabelKey(AssignWndObj,cancel,gadgCancel);
  2343.  
  2344.       DirReqObj = FileReqObject,
  2345.     ASLFR_TitleText,GetString(msgFontDirTitle),
  2346.     ASLFR_DrawersOnly,TRUE,
  2347.     ASLFR_Window,FontWnd,
  2348.       EndObject;
  2349.       if (DirReqObj == NULL) ErrorCode(NEWFILE);
  2350.     }
  2351.  
  2352.     SetAttrs(FontDirStr,STRINGA_TextVal,FontPath,TAG_DONE);
  2353.     if ((AssignWnd = WindowOpen(AssignWndObj)) == NULL)
  2354.       ErrorCode(OPENWINDOW);
  2355.   }
  2356. }
  2357.  
  2358. void CloseAssignWnd(BOOL obj)
  2359. {
  2360.   ClrWindowClose(&AssignWndObj,&AssignWnd);
  2361.   if (obj) ClrDisposeObject(&AssignWndObj);
  2362. }
  2363.  
  2364. void OpenEditCharWnd(void)
  2365. {
  2366. Object *accept, *cancel;
  2367.  
  2368.   if (EditCharWnd)
  2369.   {
  2370.     WindowToFront(EditCharWnd);
  2371.     ActivateWindow(EditCharWnd);
  2372.   }
  2373.   else
  2374.   {
  2375.     if (EditCharWndObj == NULL)
  2376.     {
  2377.       SetupMenus(Menus);
  2378.       EditCharWndObj = WindowObject,
  2379.     WINDOW_Screen,Screen,
  2380.     WINDOW_SharedPort,WndMsgPort,
  2381.     WINDOW_MenuStrip,Menus,
  2382.     WINDOW_Title,GetString(msgEditCharTitle),
  2383.     WINDOW_HelpFile,NAME".guide",
  2384.     WINDOW_HelpNode,"editchar",
  2385.     WINDOW_SmartRefresh,TRUE,
  2386.     WINDOW_SizeGadget,FALSE,
  2387.     WINDOW_CloseOnEsc,TRUE,
  2388.     WINDOW_MasterGroup,
  2389.       VGroupObject,
  2390.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(4)),
  2391.         GROUP_BackFill,SHINE_RASTER,
  2392.         StartMember,
  2393.           HGroupObject,
  2394.         HOffset(SizeX(8)),VOffset(SizeY(4)),
  2395.         EqualHeight,
  2396.         ButtonFrame,
  2397.         FRM_Recessed,TRUE,
  2398.         StartMember,
  2399.           EditCharNum = StringObject,
  2400.             RidgeFrame,
  2401.             Label(GetString(gadgCharNum)),
  2402.             STRINGA_LongVal,0,
  2403.             STRINGA_IntegerMin,0,
  2404.             STRINGA_IntegerMax,255,
  2405.             STRINGA_MaxChars,3,
  2406.             STRINGA_MinCharsVisible,4,
  2407.             GA_ID,ID_EDITCHARNUM,
  2408.           EndObject,
  2409.         EndMember,
  2410.           EndObject,
  2411.         EndMember,
  2412.         StartMember,
  2413.           HGroupObject,
  2414.         Spacing(SizeX(8)),
  2415.         StartMember,
  2416.           accept = KeyButton(GetString(gadgAccept),ID_ACCEPT),
  2417.         EndMember,
  2418.             StartMember,
  2419.           cancel = KeyButton(GetString(gadgCancel),ID_CANCEL),
  2420.         EndMember,
  2421.           EndObject,
  2422.           FixMinHeight,
  2423.         EndMember,
  2424.       EndObject,
  2425.     EndObject;
  2426.       if (EditCharWndObj == NULL) ErrorCode(NEWWINDOW);
  2427.       SetLabelKey(EditCharWndObj,accept,gadgAccept);
  2428.       SetLabelKey(EditCharWndObj,cancel,gadgCancel);
  2429.       SetAttrs(EditCharNum,STRINGA_BufferPos,1);
  2430.     }
  2431.  
  2432.     if ((EditCharWnd = WindowOpen(EditCharWndObj)) == NULL)
  2433.       ErrorCode(OPENWINDOW);
  2434.   }
  2435.   ActivateGadget((struct Gadget *)EditCharNum,EditCharWnd,NULL);
  2436. }
  2437.  
  2438. void CloseEditCharWnd(BOOL obj)
  2439. {
  2440.   ClrWindowClose(&EditCharWndObj,&EditCharWnd);
  2441.   if (obj) ClrDisposeObject(&EditCharWndObj);
  2442. }
  2443.  
  2444. void OpenWidthWnd(struct CharNode *node)
  2445. {
  2446. Object *accept, *cancel;
  2447. static ULONG lmap[] = { PGA_Top,INDIC_Level,TAG_END };
  2448. static ULONG rmap[] = { SCRL_Right,INDIC_Level,TAG_END };
  2449.  
  2450.   if (node->chln_Number < 256)
  2451.     sprintf(WidthTitle,GetString(msgWidthTitle),
  2452.       node->chln_Number,node->chln_Character->chr_Width);
  2453.   else
  2454.     sprintf(WidthTitle,GetString(msgWidthTitleBlank),
  2455.       node->chln_Character->chr_Width);
  2456.   WidthNode = node;
  2457.   WidthChar = node->chln_Character;
  2458.  
  2459.   if (WidthWnd)
  2460.   {
  2461.     SetGadgetAttrs((struct Gadget *)ChrWidthScroll,WidthWnd,NULL,
  2462.       PGA_Top,0,
  2463.       PGA_Total,1,
  2464.       PGA_Visible,1,TAG_DONE);
  2465.     SetGadgetAttrs((struct Gadget *)ChrWidthInt,WidthWnd,NULL,
  2466.       STRINGA_LongVal,WidthChar->chr_Width,TAG_DONE);
  2467.     SetAttrs(WidthWndObj,WINDOW_Title,WidthTitle,TAG_DONE);
  2468.     WindowToFront(WidthWnd);
  2469.     ActivateWindow(WidthWnd);
  2470.   }
  2471.   else
  2472.   {
  2473.     if (WidthWndObj == NULL)
  2474.     {
  2475.       SetupMenus(CharMenus);
  2476.       WidthWndObj = WindowObject,
  2477.     WINDOW_Screen,Screen,
  2478.     WINDOW_SharedPort,WndMsgPort,
  2479.     WINDOW_MenuStrip,CharMenus,
  2480.     WINDOW_HelpFile,NAME".guide",
  2481.     WINDOW_HelpNode,"width",
  2482.     WINDOW_SmartRefresh,TRUE,
  2483.     WINDOW_SizeGadget,FALSE,
  2484.     WINDOW_CloseOnEsc,TRUE,
  2485.     WINDOW_MasterGroup,
  2486.       VGroupObject,
  2487.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(4)),
  2488.         GROUP_BackFill,SHINE_RASTER,
  2489.         StartMember,
  2490.           VGroupObject,
  2491.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(2)),
  2492.         ButtonFrame,
  2493.         FRM_Recessed,TRUE,
  2494.         StartMember,
  2495.           ChrWidthInt = KeyInteger(GetString(gadgNewWidth),
  2496.             WidthChar->chr_Width,5,ID_CHARWIDTH),
  2497.         EndMember,
  2498.         StartMember,
  2499.           HGroupObject,
  2500.             Spacing(SizeX(8)),
  2501.             StartMember,
  2502.               LeftInd = IndicatorObject,
  2503.             INDIC_Min,0,
  2504.             INDIC_Max,999,
  2505.             INDIC_FormatString,GetString(msgLeftOffset),
  2506.               EndObject,
  2507.             EndMember,
  2508.             StartMember,
  2509.               RightInd = IndicatorObject,
  2510.             INDIC_Min,0,
  2511.             INDIC_Max,999,
  2512.             INDIC_FormatString,GetString(msgRightOffset),
  2513.               EndObject,
  2514.             EndMember,
  2515.           EndObject,
  2516.         EndMember,
  2517.         StartMember,
  2518.           ChrWidthScroll = NewObject(SlideClass,NULL,
  2519.             PGA_Freedom,FREEHORIZ,
  2520.             PGA_Arrows,FALSE,
  2521.             GA_ID,ID_WIDTHPOS,
  2522.           EndObject,
  2523.         EndMember,
  2524.           EndObject,
  2525.         EndMember,
  2526.         StartMember,
  2527.           HGroupObject,
  2528.         Spacing(SizeX(8)),
  2529.         StartMember,
  2530.           accept = KeyButton(GetString(gadgAccept),ID_ACCEPT),
  2531.         EndMember,
  2532.             StartMember,
  2533.           cancel = KeyButton(GetString(gadgCancel),ID_CANCEL),
  2534.         EndMember,
  2535.           EndObject,
  2536.           FixMinHeight,
  2537.         EndMember,
  2538.       EndObject,
  2539.     EndObject;
  2540.       if (WidthWndObj == NULL) ErrorCode(NEWWINDOW);
  2541.       SetLabelKey(WidthWndObj,accept,gadgAccept);
  2542.       SetLabelKey(WidthWndObj,cancel,gadgCancel);
  2543.       SetLabelKey(WidthWndObj,ChrWidthInt,gadgNewWidth);
  2544.       AddMap(ChrWidthScroll,LeftInd,lmap);
  2545.       AddMap(ChrWidthScroll,RightInd,rmap);
  2546.     }
  2547.  
  2548.     SetAttrs(ChrWidthScroll,
  2549.       PGA_Top,0,
  2550.       PGA_Total,1,
  2551.       PGA_Visible,1,TAG_DONE);
  2552.     SetAttrs(ChrWidthInt,STRINGA_LongVal,WidthChar->chr_Width,TAG_DONE);
  2553.     SetAttrs(WidthWndObj,WINDOW_Title,WidthTitle,TAG_DONE);
  2554.     if ((WidthWnd = WindowOpen(WidthWndObj)) == NULL) ErrorCode(OPENWINDOW);
  2555.   }
  2556. }
  2557.  
  2558. void CloseWidthWnd(BOOL obj)
  2559. {
  2560.   ClrWindowClose(&WidthWndObj,&WidthWnd);
  2561.   if (obj) ClrDisposeObject(&WidthWndObj);
  2562.   WidthNode = NULL; WidthChar = NULL;
  2563. }
  2564.  
  2565. void OpenKernWnd(struct CharNode *node)
  2566. {
  2567. Object *accept, *cancel;
  2568.  
  2569.   if (node->chln_Number < 256)
  2570.     sprintf(KernTitle,GetString(msgKernTitle),node->chln_Number);
  2571.   else
  2572.     sprintf(KernTitle,GetString(msgKernTitleBlank));
  2573.   KernNode = node;
  2574.   KernChar = node->chln_Character;
  2575.  
  2576.   if (KernWnd)
  2577.   {
  2578.     SetAttrs(KernWndObj,WINDOW_Title,KernTitle,TAG_DONE);
  2579.     SetGadgetAttrs((struct Gadget *)SpaceObj,KernWnd,NULL,
  2580.       STRINGA_LongVal,SpaceTable[node->chln_Number],TAG_DONE);
  2581.     SetGadgetAttrs((struct Gadget *)KernObj,KernWnd,NULL,
  2582.       STRINGA_LongVal,KernTable[node->chln_Number],TAG_DONE);
  2583.     WindowToFront(KernWnd);
  2584.     ActivateWindow(KernWnd);
  2585.   }
  2586.   else
  2587.   {
  2588.     if (KernWndObj == NULL)
  2589.     {
  2590.       SetupMenus(CharMenus);
  2591.       KernWndObj = WindowObject,
  2592.     WINDOW_Screen,Screen,
  2593.     WINDOW_SharedPort,WndMsgPort,
  2594.     WINDOW_MenuStrip,CharMenus,
  2595.     WINDOW_HelpFile,NAME".guide",
  2596.     WINDOW_HelpNode,"kern",
  2597.     WINDOW_ScaleWidth,11,
  2598.     WINDOW_SmartRefresh,TRUE,
  2599.     WINDOW_SizeGadget,FALSE,
  2600.     WINDOW_CloseOnEsc,TRUE,
  2601.     WINDOW_MasterGroup,
  2602.       VGroupObject,
  2603.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(4)),
  2604.         GROUP_BackFill,SHINE_RASTER,
  2605.         StartMember,
  2606.           VGroupObject,
  2607.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(2)),
  2608.         ButtonFrame,
  2609.         FRM_Recessed,TRUE,
  2610.         StartMember,
  2611.           SpaceObj = TabKeyInteger(GetString(gadgSpacing),0,5,
  2612.             ID_SPACE),
  2613.         EndMember,
  2614.         StartMember,
  2615.           KernObj = TabKeyInteger(GetString(gadgKerning),0,5,
  2616.             ID_KERN),
  2617.         EndMember,
  2618.           EndObject,
  2619.         EndMember,
  2620.         StartMember,
  2621.           HGroupObject,
  2622.         Spacing(SizeX(8)),
  2623.         StartMember,
  2624.           accept = KeyButton(GetString(gadgAccept),ID_ACCEPT),
  2625.         EndMember,
  2626.             StartMember,
  2627.           cancel = KeyButton(GetString(gadgCancel),ID_CANCEL),
  2628.         EndMember,
  2629.           EndObject,
  2630.           FixMinHeight,
  2631.         EndMember,
  2632.       EndObject,
  2633.     EndObject;
  2634.       if (KernWndObj == NULL) ErrorCode(NEWWINDOW);
  2635.       SetLabelKey(KernWndObj,accept,gadgAccept);
  2636.       SetLabelKey(KernWndObj,cancel,gadgCancel);
  2637.       SetLabelKey(KernWndObj,SpaceObj,gadgSpacing);
  2638.       SetLabelKey(KernWndObj,KernObj,gadgKerning);
  2639.       DoMethod(KernWndObj,WM_TABCYCLE_ORDER,SpaceObj,KernObj,NULL);
  2640.     }
  2641.  
  2642.     SetAttrs(KernWndObj,WINDOW_Title,KernTitle,TAG_DONE);
  2643.     SetAttrs(SpaceObj,
  2644.       STRINGA_LongVal,SpaceTable[node->chln_Number],TAG_DONE);
  2645.     SetAttrs(KernObj,STRINGA_LongVal,KernTable[node->chln_Number],TAG_DONE);
  2646.     if ((KernWnd = WindowOpen(KernWndObj)) == NULL) ErrorCode(OPENWINDOW);
  2647.   }
  2648. }
  2649.  
  2650. void CloseKernWnd(BOOL obj)
  2651. {
  2652.   ClrWindowClose(&KernWndObj,&KernWnd);
  2653.   if (obj) ClrDisposeObject(&KernWndObj);
  2654.   KernNode = NULL; KernChar = NULL;
  2655. }
  2656.  
  2657. void OpenSaveWnd(void)
  2658. {
  2659. Object *save, *cancel;
  2660. ULONG satan = 666;
  2661.  
  2662.   if (SaveWnd)
  2663.   {
  2664.     WindowToFront(SaveWnd);
  2665.     ActivateWindow(SaveWnd);
  2666.   }
  2667.   else
  2668.   {
  2669.     if (SaveWndObj == NULL)
  2670.     {
  2671.       SaveWndObj = WindowObject,
  2672.     WINDOW_Screen,Screen,
  2673.     WINDOW_SharedPort,WndMsgPort,
  2674.     WINDOW_Title,GetString(msgSaveTitle),
  2675.     WINDOW_HelpFile,NAME".guide",
  2676.     WINDOW_HelpNode,"save",
  2677.     WINDOW_SmartRefresh,TRUE,
  2678.     WINDOW_SizeGadget,FALSE,
  2679.     WINDOW_RMBTrap,TRUE,
  2680.     WINDOW_CloseOnEsc,TRUE,
  2681.     WINDOW_MasterGroup,
  2682.       VGroupObject,
  2683.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(4)),
  2684.         GROUP_BackFill,SHINE_RASTER,
  2685.         StartMember,
  2686.           VGroupObject,
  2687.         HOffset(SizeX(8)),VOffset(SizeY(4)),Spacing(SizeY(2)),
  2688.         ButtonFrame,
  2689.         FRM_Recessed,TRUE,
  2690.         StartMember,
  2691.           HGroupObject,
  2692.             VarSpace(0),
  2693.             StartMember,
  2694.               SaveDirStr = StringObject,
  2695.             RidgeFrame,
  2696.             UScoreLabel(GetString(gadgFontDir),'_'),
  2697.             STRINGA_MaxChars,255,
  2698.             GA_TabCycle,TRUE,
  2699.             GA_ID,ID_SAVEDIR,
  2700.               EndObject,
  2701.             EndMember,
  2702.             StartMember,
  2703.               ButtonObject,
  2704.             GetPath,
  2705.             ButtonFrame,
  2706.             GA_ID,ID_GETSAVEDIR,
  2707.               EndObject,
  2708.               FixMinWidth,
  2709.             EndMember,
  2710.           EndObject,
  2711.           NoAlign,
  2712.         EndMember,
  2713.         StartMember,
  2714.           HGroupObject,
  2715.             Spacing(SizeX(8)),
  2716.             StartMember,
  2717.               FontNameStr = StringObject,
  2718.             RidgeFrame,
  2719.             UScoreLabel(GetString(gadgFontName),'_'),
  2720.             STRINGA_MaxChars,255,
  2721.             GA_TabCycle,TRUE,
  2722.             GA_ID,ID_FONTNAME,
  2723.               EndObject,
  2724.             EndMember,
  2725.             StartMember,
  2726.               SizeInfo = InfoObject,
  2727.             ButtonFrame,
  2728.             FRM_Flags,FRF_RECESSED,
  2729.             Label(GetString(msgSize)),
  2730.             INFO_TextFormat,"\33c%.2ld",
  2731.             INFO_Args,&satan,
  2732.             INFO_MinLines,1,
  2733.             INFO_HorizOffset,6,
  2734.             INFO_VertOffset,3,
  2735.             INFO_FixTextWidth,TRUE,
  2736.               EndObject,
  2737.               Weight(10),
  2738.             EndMember,
  2739.           EndObject,
  2740.         EndMember,
  2741.         StartMember,
  2742.           HGroupObject,
  2743.             Spacing(SizeX(8)),
  2744.             StartMember,
  2745.               FirstNum = StringObject,
  2746.             RidgeFrame,
  2747.             UScoreLabel(GetString(gadgFirst),'_'),
  2748.             STRINGA_LongVal,0,
  2749.             STRINGA_MaxChars,3,
  2750.             STRINGA_MinCharsVisible,4,
  2751.             GA_TabCycle,TRUE,
  2752.             GA_ID,ID_FIRST,
  2753.               EndObject,
  2754.             EndMember,
  2755.             StartMember,
  2756.               LastNum = StringObject,
  2757.             RidgeFrame,
  2758.             UScoreLabel(GetString(gadgLast),'_'),
  2759.             STRINGA_LongVal,0,
  2760.             STRINGA_MaxChars,3,
  2761.             STRINGA_MinCharsVisible,4,
  2762.             GA_TabCycle,TRUE,
  2763.             GA_ID,ID_LAST,
  2764.               EndObject,
  2765.             EndMember,
  2766.             StartMember,
  2767.               VGroupObject,
  2768.             VarSpace(60),
  2769.             StartMember,
  2770.               TableCheck = KeyCheckBox(GetString(gadgKernInfo),
  2771.                 FALSE,ID_KERNTABLE),
  2772.             EndMember,
  2773.             VarSpace(50),
  2774.               EndObject,
  2775.             EndMember,
  2776.           EndObject,
  2777.         EndMember,
  2778.           EndObject,
  2779.         EndMember,
  2780.         StartMember,
  2781.           HGroupObject,
  2782.         Spacing(SizeX(8)),
  2783.         StartMember,
  2784.           save = KeyButton(GetString(gadgSave),ID_ACCEPT),
  2785.         EndMember,
  2786.             StartMember,
  2787.           cancel = KeyButton(GetString(gadgCancel),ID_CANCEL),
  2788.         EndMember,
  2789.           EndObject,
  2790.           FixMinHeight,
  2791.         EndMember,
  2792.       EndObject,
  2793.     EndObject;
  2794.       if (SaveWndObj == NULL) ErrorCode(NEWWINDOW);
  2795.       SetLabelKey(SaveWndObj,save,gadgSave);
  2796.       SetLabelKey(SaveWndObj,cancel,gadgCancel);
  2797.       SetLabelKey(SaveWndObj,SaveDirStr,gadgFontDir);
  2798.       SetLabelKey(SaveWndObj,FontNameStr,gadgFontName);
  2799.       SetLabelKey(SaveWndObj,FirstNum,gadgFirst);
  2800.       SetLabelKey(SaveWndObj,LastNum,gadgLast);
  2801.       SetLabelKey(SaveWndObj,TableCheck,gadgKernInfo);
  2802.       DoMethod(SaveWndObj,WM_TABCYCLE_ORDER,
  2803.     SaveDirStr,FontNameStr,FirstNum,LastNum,NULL);
  2804.  
  2805.       SaveReqObj = FileReqObject,
  2806.     ASLFR_TitleText,GetString(msgFontDirTitle),
  2807.     ASLFR_DrawersOnly,TRUE,
  2808.       EndObject;
  2809.       if (SaveReqObj == NULL) ErrorCode(NEWFILE);
  2810.     }
  2811.  
  2812.     SleepWindows();
  2813.     SetAttrs(SaveDirStr,STRINGA_TextVal,SavePath,TAG_DONE);
  2814.     SetAttrs(FontNameStr,STRINGA_TextVal,FontName,TAG_DONE);
  2815.     SetAttrs(FirstNum,STRINGA_LongVal,FirstChar,TAG_DONE);
  2816.     SetAttrs(LastNum,STRINGA_LongVal,LastChar,TAG_DONE);
  2817.     SetAttrs(SizeInfo,INFO_Args,&Height,TAG_DONE);
  2818.     SetAttrs(TableCheck,
  2819.       GA_Disabled,Proportional == TRUE,
  2820.       GA_Selected,(Proportional == TRUE) || (UseTable == TRUE),TAG_DONE);
  2821.     if ((SaveWnd = WindowOpen(SaveWndObj)) == NULL) ErrorCode(OPENWINDOW);
  2822.   }
  2823. }
  2824.  
  2825. void CloseSaveWnd(void)
  2826. {
  2827.   WakeWindows();
  2828.   ClrWindowClose(&SaveWndObj,&SaveWnd);
  2829.   ClrDisposeObject(&SaveWndObj);
  2830. }
  2831.  
  2832. void OpenAboutWnd(void)
  2833. {
  2834. static struct EasyStruct req =
  2835.   { sizeof(struct EasyStruct),0,NAME,
  2836.     NAME" "VERSION" © 1995-96 David Kinder\n\n"
  2837.     "%s\n\n%s%s: %ld Kb\n%s: %ld Kb",NULL };
  2838.  
  2839.   SleepWindows();
  2840.   req.es_GadgetFormat = GetString(msgContinue);
  2841.   EasyRequest(FontWnd,&req,NULL,
  2842.     TEXTFIELD_GetCopyright(),
  2843.     GetString(msgTranslator),
  2844.     GetString(msgFreeChip),AvailMem(MEMF_CHIP)/1024,
  2845.     GetString(msgFreeFast),AvailMem(MEMF_FAST)/1024);
  2846.   WakeWindows();
  2847. }
  2848.  
  2849. void PutPositive(struct Window *wnd, char *name, LONG value, LONG min,
  2850.   LONG *dest)
  2851. {
  2852.   if (value > min)
  2853.   {
  2854.     *dest = value;
  2855.   }
  2856.   else
  2857.   {
  2858.     ShowReq(GetString(msgPutPositive),GetString(msgContinue),name,min);
  2859.     FlagError = TRUE;
  2860.   }
  2861. }
  2862.  
  2863. void NewHeights(void)
  2864. {
  2865. struct Character *chr;
  2866. ULONG i;
  2867. UBYTE *new_char;
  2868.  
  2869.   for (i = 0; i < 257; i++)
  2870.   {
  2871.     chr = CharBuffer+i;
  2872.     if (chr->chr_Data)
  2873.     {
  2874.       if ((new_char = AllocVec(chr->chr_Width*Height,MEMF_CLEAR)) == NULL)
  2875.     ErrorCode(ALLOCVEC);
  2876.       CopyMem(chr->chr_Data,new_char,
  2877.     MIN(chr->chr_Height,Height)*chr->chr_Width);
  2878.       FreeVec(chr->chr_Data);
  2879.       chr->chr_Data = new_char;
  2880.     }
  2881.     chr->chr_Height = Height;
  2882.   }
  2883.   sprintf(WinTitle,"%s/%ld",FontName,Height);
  2884.   SetAttrs(FontWndObj,WINDOW_Title,WinTitle,TAG_DONE);
  2885. }
  2886.  
  2887. void NewWidths(void)
  2888. {
  2889. struct Character *chr;
  2890. ULONG i;
  2891.  
  2892.   for (i = 0; i < 257; i++)
  2893.   {
  2894.     chr = CharBuffer+i;
  2895.     if (chr->chr_Data) ChangeCharWidth(chr,Width,0,0);
  2896.     chr->chr_Width = Width;
  2897.   }
  2898. }
  2899.  
  2900. void ChangeCharWidth(struct Character *chr, ULONG width, ULONG newoffset,
  2901.   ULONG oldoffset)
  2902. {
  2903. ULONG j;
  2904. UBYTE *data = NULL;
  2905.  
  2906.   if ((width > 0) && (chr->chr_Data))
  2907.   {
  2908.     if ((data = AllocVec(width*Height,MEMF_CLEAR)) == NULL)
  2909.       ErrorCode(ALLOCVEC);
  2910.     for (j = 0; j < Height; j++)
  2911.       CopyMem(chr->chr_Data+(j*chr->chr_Width)+oldoffset,
  2912.       data+(j*width)+newoffset,MIN(chr->chr_Width,width));
  2913.   }
  2914.   if (chr->chr_Data) FreeVec(chr->chr_Data);
  2915.   if (Reversed == FALSE)
  2916.     SpaceTable[chr-CharBuffer] += (width-chr->chr_Width);
  2917.   chr->chr_Data = data;
  2918.   chr->chr_Width = width;
  2919.   CheckWidthKern(chr);
  2920. }
  2921.  
  2922. void CheckWidthKern(struct Character *chr)
  2923. {
  2924.   if (chr == WidthChar)
  2925.   {
  2926.     if (WidthNode->chln_Number < 256)
  2927.       sprintf(WidthTitle,GetString(msgWidthTitle),
  2928.         WidthNode->chln_Number,WidthChar->chr_Width);
  2929.     else
  2930.       sprintf(WidthTitle,GetString(msgWidthTitleBlank),
  2931.     WidthChar->chr_Width);
  2932.     SetGadgetAttrs((struct Gadget *)ChrWidthScroll,WidthWnd,NULL,
  2933.       PGA_Top,0,
  2934.       PGA_Total,1,
  2935.       PGA_Visible,1,TAG_DONE);
  2936.     SetGadgetAttrs((struct Gadget *)ChrWidthInt,WidthWnd,NULL,
  2937.       STRINGA_LongVal,WidthChar->chr_Width,TAG_DONE);
  2938.     SetAttrs(WidthWndObj,WINDOW_Title,WidthTitle,TAG_DONE);
  2939.   }
  2940.   if (chr == KernChar)
  2941.     SetGadgetAttrs((struct Gadget *)SpaceObj,KernWnd,NULL,
  2942.       STRINGA_LongVal,SpaceTable[KernNode->chln_Number],TAG_DONE);
  2943. }
  2944.  
  2945. void SavePrefs(char *filename)
  2946. {
  2947. BPTR file;
  2948.  
  2949.   SleepWindows();
  2950.   Prefs.Flags = 0;
  2951.   if (NewCustom) Prefs.Flags |= PREFS_CUSTOMSCREEN;
  2952.   if (MaxWindow) Prefs.Flags |= PREFS_MAXWINDOW;
  2953.   if (ConfirmQuit) Prefs.Flags |= PREFS_CONFIRMQUIT;
  2954.   if (QueryWidth) Prefs.Flags |= PREFS_QUERYWIDTH;
  2955.   if (ShowBLine) Prefs.Flags |= PREFS_SHOWBASELINE;
  2956.   if (AutoHeight) Prefs.Flags |= PREFS_AUTOTBARHEIGHT;
  2957.   if (InvertShift) Prefs.Flags |= PREFS_INVERTSHIFT;
  2958.   if (Toggle == 0) Prefs.Flags |= PREFS_NOTOGGLE;
  2959.   switch (PixelBorder)
  2960.   {
  2961.     case 1:
  2962.       Prefs.Flags |= PREFS_PIXELBORDER;
  2963.       break;
  2964.     case 2:
  2965.       Prefs.Flags |= PREFS_PIXELGRID;
  2966.       break;
  2967.   }
  2968.   if (file = Open(filename,MODE_NEWFILE))
  2969.   {
  2970.     Write(file,&Prefs,sizeof(struct Preferences));
  2971.     Close(file);
  2972.   }
  2973.   else ShowReq(GetString(msgPrefsSaveError),GetString(msgContinue),filename);
  2974.   WakeWindows();
  2975. }
  2976.  
  2977. void LoadPrefs(void)
  2978. {
  2979. BPTR file;
  2980.  
  2981.   if ((file = Open("ENV:"NAME".prefs",MODE_OLDFILE)) == 0)
  2982.     file = Open("PROGDIR:"NAME".prefs",MODE_OLDFILE);
  2983.   if (file)
  2984.   {
  2985.     Read(file,&Prefs,sizeof(struct Preferences));
  2986.     Close(file);
  2987.     if (Prefs.Version >= 1)
  2988.     {
  2989.       CustomScreen = (Prefs.Flags & PREFS_CUSTOMSCREEN) ? TRUE : FALSE;
  2990.       MaxWindow = (Prefs.Flags & PREFS_MAXWINDOW) ? TRUE : FALSE;
  2991.       ConfirmQuit = (Prefs.Flags & PREFS_CONFIRMQUIT) ? TRUE : FALSE;
  2992.       QueryWidth = (Prefs.Flags & PREFS_QUERYWIDTH) ? TRUE : FALSE;
  2993.       ShowBLine = (Prefs.Flags & PREFS_SHOWBASELINE) ? TRUE : FALSE;
  2994.       AutoHeight = (Prefs.Flags & PREFS_AUTOTBARHEIGHT) ? TRUE : FALSE;
  2995.       InvertShift = (Prefs.Flags & PREFS_INVERTSHIFT) ? TRUE : FALSE;
  2996.       Toggle = (Prefs.Flags & PREFS_NOTOGGLE) ? FALSE : TRUE;
  2997.       PixelBorder = 0;
  2998.       if (Prefs.Flags & PREFS_PIXELBORDER) PixelBorder = 1;
  2999.       if (Prefs.Flags & PREFS_PIXELGRID) PixelBorder = 2;
  3000.     }
  3001.     Prefs.Version = CURRENT_PREFS;
  3002.   }
  3003. }
  3004.  
  3005. void FlushAllFonts(void)
  3006. {
  3007. UBYTE *free;
  3008.  
  3009.   if ((free = AllocMem(~0,MEMF_ANY)) != NULL) FreeMem(free,~0);
  3010. }
  3011.  
  3012. void GetScreenRatio(struct Screen *scr)
  3013. {
  3014. ULONG vti[4];
  3015. struct ViewPortExtra *vpe;
  3016.  
  3017.   ScaleX = 1000;
  3018.   ScaleY = 1000;
  3019.   ScrWidth = scr->Width;
  3020.   ScrHeight = scr->Height;
  3021.   if (scr->ViewPort.ColorMap)
  3022.   {
  3023.     vti[0] = VTAG_VIEWPORTEXTRA_GET;
  3024.     vti[1] = 0;
  3025.     vti[2] = VTAG_END_CM;
  3026.     vti[3] = 0;
  3027.     if (VideoControl(scr->ViewPort.ColorMap,vti) == 0)
  3028.     {
  3029.       vpe = (struct ViewPortExtra *)vti[1];
  3030.       ScrWidth = vpe->DisplayClip.MaxX - vpe->DisplayClip.MinX + 1;
  3031.       ScrHeight = vpe->DisplayClip.MaxY - vpe->DisplayClip.MinY + 1;
  3032.       ScaleX = MAX((ScrWidth*1000)/640,1000);
  3033.       ScaleY = MAX((ScrHeight*1000)/256,1000);
  3034.     }
  3035.   }
  3036. }
  3037.  
  3038. LONG SizeX(LONG x)
  3039. {
  3040.   return ((x*ScaleX)/1000);
  3041. }
  3042.  
  3043. LONG SizeY(LONG y)
  3044. {
  3045.   return ((y*ScaleY)/1000);
  3046. }
  3047.  
  3048. void WriteFont(char *buffer, char *name, UWORD height)
  3049. {
  3050. char *endptr;
  3051.  
  3052.   strcpy(buffer,name);
  3053.   if (endptr = strstr(buffer,".font")) *endptr = 0;
  3054.   sprintf(buffer+strlen(buffer),"/%d",height);
  3055. }
  3056.  
  3057. char *GetPubName(BOOL screen)
  3058. {
  3059.   return (screen ? PrefThisPubName : PrefDefPubName);
  3060. }
  3061.  
  3062. void CopyPubName(void)
  3063. {
  3064. ULONG custom;
  3065. char *name;
  3066.  
  3067.   GetAttr(GA_Selected,CustButton,&custom);
  3068.   GetAttr(STRINGA_TextVal,PubStr,(ULONG *)&name);
  3069.   strcpy(custom ? PrefThisPubName : PrefDefPubName,name);
  3070. }
  3071.  
  3072. void WarnVisitors(void)
  3073. {
  3074. struct bguiRequest *visitors;
  3075.  
  3076.   if (visitors = AllocVec(sizeof(struct bguiRequest),MEMF_CLEAR))
  3077.   {
  3078.     visitors->br_Flags = BREQF_FAST_KEYS;
  3079.     visitors->br_Title = NAME;
  3080.     visitors->br_GadgetFormat = GetString(msgContinue);
  3081.     visitors->br_TextFormat = GetString(msgVisitors);
  3082.     visitors->br_ReqPos = POS_TOPLEFT;
  3083.     visitors->br_Screen = Screen;
  3084.     BGUI_Request(NULL,visitors);
  3085.     FreeVec(visitors);
  3086.   }
  3087. }
  3088.  
  3089. void CheckQuit(void)
  3090. {
  3091.   if (ConfirmQuit == FALSE) Quit();
  3092.   if (ShowReq(GetString(msgCheckQuit),GetString(msgQuitCancel),
  3093.     DataChanged ? GetString(msgCharsChanged) : (STRPTR)"") == 1) Quit();
  3094. }
  3095.  
  3096. void AddToolBarList(UWORD entry)
  3097. {
  3098.   AddEntry(NULL,(Prefs.ToolBar & entry) ? ToolBarIn : ToolBarOut,entry,LVAP_SORTED);
  3099. }
  3100.  
  3101. void CascadeWindows()
  3102. {
  3103. struct CharNode *node;
  3104. struct IBox bounds;
  3105. WORD x,y;
  3106.  
  3107.   x = CharSize.Left;
  3108.   y = CharSize.Top;
  3109.   node = (struct CharNode *)CharWndList->lh_Head;
  3110.   while (node->chln_Node.ln_Succ)
  3111.   {
  3112.     GetAttr(WINDOW_Bounds,node->chln_Object,(ULONG *)&bounds);
  3113.     if (y+bounds.Height > node->chln_Window->WScreen->Height)
  3114.     {
  3115.       x += node->chln_Window->RPort->TxWidth*3;
  3116.       y = CharSize.Top;
  3117.     }
  3118.     bounds.Left = x;
  3119.     bounds.Top = y;
  3120.     SetAttrs(node->chln_Object,WINDOW_Bounds,&bounds,TAG_DONE);
  3121.     WindowToFront(node->chln_Window);
  3122.     ActivateWindow(node->chln_Window);
  3123.     x += node->chln_Window->BorderLeft;
  3124.     y += node->chln_Window->BorderTop;
  3125.     node = (struct CharNode *)node->chln_Node.ln_Succ;
  3126.   }
  3127. }
  3128.